Skip to content

Commit cb9ebe7

Browse files
committed
add ability to know if an attribute is a metric
1 parent 44eabdc commit cb9ebe7

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,9 @@ public static boolean dataTypeEquals(List<Attribute> left, List<Attribute> right
154154
* @return true if the attribute represents a TSDB dimension type
155155
*/
156156
public abstract boolean isDimension();
157+
158+
/**
159+
* @return true if the attribute represents a TSDB metric type
160+
*/
161+
public abstract boolean isMetric();
157162
}

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public boolean isDimension() {
4949
return false;
5050
}
5151

52+
@Override
53+
public boolean isMetric() {
54+
return false;
55+
}
56+
5257
@Override
5358
public boolean resolved() {
5459
return true;

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ public boolean isDimension() {
221221
return field.getTimeSeriesFieldType() == EsField.TimeSeriesFieldType.DIMENSION;
222222
}
223223

224+
@Override
225+
public boolean isMetric() {
226+
return field.getTimeSeriesFieldType() == EsField.TimeSeriesFieldType.METRIC;
227+
}
228+
224229
public EsField field() {
225230
return field;
226231
}

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ protected String label() {
122122

123123
@Override
124124
public boolean isDimension() {
125+
// Metadata attributes cannot be dimensions. I think?
126+
return false;
127+
}
128+
129+
@Override
130+
public boolean isMetric() {
131+
// Metadata attributes definitely cannot be metrics.
125132
return false;
126133
}
127134

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/ReferenceAttribute.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,9 @@ protected String label() {
122122
public boolean isDimension() {
123123
return false;
124124
}
125+
126+
@Override
127+
public boolean isMetric() {
128+
return false;
129+
}
125130
}

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ public boolean isDimension() {
112112
return false;
113113
}
114114

115+
@Override
116+
public boolean isMetric() {
117+
return false;
118+
}
119+
115120
@Override
116121
public String nodeString() {
117122
return toString();

0 commit comments

Comments
 (0)