Skip to content

Esql dimension aware attributes #131463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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 @@ -92,7 +92,8 @@ public void setup() {
var fields = 10_000;
var mapping = LinkedHashMap.<String, EsField>newLinkedHashMap(fields);
for (int i = 0; i < fields; i++) {
mapping.put("field" + i, new EsField("field-" + i, TEXT, emptyMap(), true));
// We're creating a standard index, so none of these fields should be marked as dimensions.
mapping.put("field" + i, new EsField("field-" + i, TEXT, emptyMap(), true, EsField.TimeSeriesFieldType.NONE));
}

var esIndex = new EsIndex("test", mapping, Map.of("test", IndexMode.STANDARD));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
FieldAttribute timestamp = new FieldAttribute(
Source.EMPTY,
"timestamp",
new EsField("timestamp", DataType.DATETIME, Map.of(), true)
new EsField("timestamp", DataType.DATETIME, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
);
yield EvalMapper.toEvaluator(
FOLD_CONTEXT,
Expand Down Expand Up @@ -321,19 +321,35 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
}

private static FieldAttribute longField() {
return new FieldAttribute(Source.EMPTY, "long", new EsField("long", DataType.LONG, Map.of(), true));
return new FieldAttribute(
Source.EMPTY,
"long",
new EsField("long", DataType.LONG, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
);
}

private static FieldAttribute doubleField() {
return new FieldAttribute(Source.EMPTY, "double", new EsField("double", DataType.DOUBLE, Map.of(), true));
return new FieldAttribute(
Source.EMPTY,
"double",
new EsField("double", DataType.DOUBLE, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
);
}

private static FieldAttribute intField() {
return new FieldAttribute(Source.EMPTY, "int", new EsField("int", DataType.INTEGER, Map.of(), true));
return new FieldAttribute(
Source.EMPTY,
"int",
new EsField("int", DataType.INTEGER, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
);
}

private static FieldAttribute keywordField() {
return new FieldAttribute(Source.EMPTY, "keyword", new EsField("keyword", DataType.KEYWORD, Map.of(), true));
return new FieldAttribute(
Source.EMPTY,
"keyword",
new EsField("keyword", DataType.KEYWORD, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
);
}

private static Configuration configuration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
| boolean | boolean |
| cartesian_point | boolean |
| cartesian_shape | boolean |
| counter_double | boolean |
| counter_integer | boolean |
| counter_long | boolean |
| date | boolean |
| date_nanos | boolean |
| double | boolean |
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,9 @@ public String nodeString() {
}

protected abstract String label();

/**
* @return true if the attribute represents a TSDB dimension type
*/
public abstract boolean isDimension();
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ protected String label() {
return "e";
}

@Override
public boolean isDimension() {
return false;
}

@Override
public boolean resolved() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ protected String label() {
return "f";
}

@Override
public boolean isDimension() {
return field.getTimeSeriesFieldType() == EsField.TimeSeriesFieldType.DIMENSION;
}

public EsField field() {
return field;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ protected String label() {
return "m";
}

@Override
public boolean isDimension() {
return false;
}

@Override
protected NodeInfo<? extends Expression> info() {
return NodeInfo.create(this, MetadataAttribute::new, name(), dataType(), nullable(), id(), synthetic(), searchable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,9 @@ protected NodeInfo<ReferenceAttribute> info() {
protected String label() {
return "r";
}

@Override
public boolean isDimension() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ protected String label() {
return UNRESOLVED_PREFIX;
}

@Override
public boolean isDimension() {
return false;
}

@Override
public String nodeString() {
return toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
public class DateEsField extends EsField {

public static DateEsField dateEsField(String name, Map<String, EsField> properties, boolean hasDocValues) {
return new DateEsField(name, DataType.DATETIME, properties, hasDocValues, TimeSeriesFieldType.UNKNOWN);
public static DateEsField dateEsField(String name, Map<String, EsField> properties, boolean hasDocValues, TimeSeriesFieldType tsType) {
return new DateEsField(name, DataType.DATETIME, properties, hasDocValues, tsType);
}

private DateEsField(
Expand Down
Loading
Loading