Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,33 @@
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;
import org.elasticsearch.xpack.esql.core.type.EsField;
import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;

import java.io.IOException;
import java.util.Map;

/**
* Attribute for referencing the TSDB metric temporality.
* The name of the field is defined per index using the
* {@link org.elasticsearch.index.IndexSettings#TIME_SERIES_TEMPORALITY_FIELD} index setting.
* If an index does not have this setting, the temporality will always be null.
*/
public final class TemporalityAttribute extends FieldAttribute {
public final class TemporalityAttribute extends TypedAttribute {

public static final String NAME = "<temporality>";
Comment thread
JonasKunz marked this conversation as resolved.

static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
Attribute.class,
"TemporalityAttribute",
TemporalityAttribute::readFrom
);

/**
* At the time the attribute is created, we don't know the field name yet.
* Therefore, we use this name as a placeholder, which we'll resolve to the actual field block loader
* (or a constant-null loader if no temporality field exists) during physical planning.
*/
private static final String DUMMY_FIELD_NAME = "_temporality_placeholder";

private static final EsField ES_FIELD = new EsField(
DUMMY_FIELD_NAME,
DataType.KEYWORD,
Map.of(),
false,
EsField.TimeSeriesFieldType.DIMENSION
);

public TemporalityAttribute(Source source) {
this(source, null);
}

private TemporalityAttribute(Source source, @Nullable NameId id) {
super(source, null, null, DUMMY_FIELD_NAME, ES_FIELD, Nullability.TRUE, id, false);
TemporalityAttribute(Source source, @Nullable NameId id) {
Comment thread
JonasKunz marked this conversation as resolved.
Outdated
super(source, NAME, DataType.KEYWORD, Nullability.TRUE, id, true);
Comment thread
JonasKunz marked this conversation as resolved.
Outdated
}

@Override
Expand Down Expand Up @@ -98,4 +83,20 @@ protected TemporalityAttribute clone(
// Ignore everything except for the source and id
return new TemporalityAttribute(source, id);
}

@Override
protected String label() {
return "";
}

@Override
public boolean isDimension() {
// temporality must be a dimension by definiton
return true;
}

@Override
public boolean isMetric() {
return false;
}
}
Loading