Class ResultColumn
- java.lang.Object
-
- org.apache.iotdb.db.mpp.plan.expression.ResultColumn
-
public class ResultColumn extends java.lang.ObjectResultColumnis used to represent a result column of a query.Assume that we have time series in db as follows:
[ root.sg.d.a, root.sg.d.b, root.sg.e.a, root.sg.e.b ]-
Example 1: select a, a + b, udf(udf(b)) from root.sg.d, root.sg.e;
- Step 1: constructed by ASTVisitor in StatementGenerator:
result columns:
[a, a + b, udf(udf(b))] - Step 2: concatenated with prefix paths:
result columns:
[root.sg.d.a, root.sg.e.a, root.sg.d.a + root.sg.d.b, root.sg.d.a + root.sg.e.b, root.sg.e.a + root.sg.d.b, root.sg.e.a + root.sg.e.b, udf(udf(root.sg.d.b)), udf(udf(root.sg.e.b))] - Step 3: remove wildcards:
result columns:
[root.sg.d.a, root.sg.e.a, root.sg.d.a + root.sg.d.b, root.sg.d.a + root.sg.e.b, root.sg.e.a + root.sg.d.b, root.sg.e.a + root.sg.e.b, udf(udf(root.sg.d.b)), udf(udf(root.sg.e.b))]
-
Example 2: select *, a + *, udf(udf(*)) from root.sg.d;
- Step 1: constructed by ASTVisitor in StatementGenerator:
result columns:
[*, a + * , udf(udf(*))] - Step 2: concatenated with prefix paths:
result columns:
[root.sg.d.*, root.sg.d.a + root.sg.d.*, udf(udf(root.sg.d.*))] - Step 3: remove wildcards:
result columns:
[root.sg.d.a, root.sg.d.b, root.sg.d.a + root.sg.d.a, root.sg.d.a + root.sg.d.b, udf(udf(root.sg.d.a)), udf(udf(root.sg.d.b))]
- Step 1: constructed by ASTVisitor in StatementGenerator:
-
-
Constructor Summary
Constructors Constructor Description ResultColumn(java.nio.ByteBuffer byteBuffer)ResultColumn(Expression expression)ResultColumn(Expression expression, java.lang.String alias)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<org.apache.iotdb.commons.path.PartialPath>collectPaths()voidconcat(java.util.List<org.apache.iotdb.commons.path.PartialPath> prefixPaths, java.util.List<ResultColumn> resultColumns, boolean needAliasCheck)static ResultColumndeserialize(java.nio.ByteBuffer byteBuffer)booleanequals(java.lang.Object o)java.lang.StringgetAlias()org.apache.iotdb.tsfile.file.metadata.enums.TSDataTypegetDataType()ExpressiongetExpression()java.lang.StringgetExpressionString()java.lang.StringgetResultColumnName()booleanhasAlias()inthashCode()voidremoveWildcards(WildcardsRemover wildcardsRemover, java.util.List<ResultColumn> resultColumns, boolean needAliasCheck)static voidserialize(ResultColumn resultColumn, java.nio.ByteBuffer byteBuffer)voidsetDataType(org.apache.iotdb.tsfile.file.metadata.enums.TSDataType dataType)java.lang.StringtoString()
-
-
-
Constructor Detail
-
ResultColumn
public ResultColumn(Expression expression, java.lang.String alias)
-
ResultColumn
public ResultColumn(Expression expression)
-
ResultColumn
public ResultColumn(java.nio.ByteBuffer byteBuffer)
-
-
Method Detail
-
concat
public void concat(java.util.List<org.apache.iotdb.commons.path.PartialPath> prefixPaths, java.util.List<ResultColumn> resultColumns, boolean needAliasCheck) throws LogicalOptimizeException- Parameters:
prefixPaths- prefix paths in the from clauseresultColumns- used to collect the result columnsneedAliasCheck- used to skip illegal alias judgement here. Including !isGroupByLevel because count(*) may be * unfolded to more than one expression, but it still can be aggregated together later.- Throws:
LogicalOptimizeException
-
removeWildcards
public void removeWildcards(WildcardsRemover wildcardsRemover, java.util.List<ResultColumn> resultColumns, boolean needAliasCheck) throws LogicalOptimizeException
- Parameters:
wildcardsRemover- used to remove wildcards fromexpressionand apply slimit & soffset controlresultColumns- used to collect the result columnsneedAliasCheck- used to skip illegal alias judgement here. Including !isGroupByLevel because count(*) may be * unfolded to more than one expression, but it still can be aggregated together later.- Throws:
LogicalOptimizeException
-
collectPaths
public java.util.List<org.apache.iotdb.commons.path.PartialPath> collectPaths()
-
getExpression
public Expression getExpression()
-
hasAlias
public boolean hasAlias()
-
getAlias
public java.lang.String getAlias()
-
getResultColumnName
public java.lang.String getResultColumnName()
-
getExpressionString
public java.lang.String getExpressionString()
-
setDataType
public void setDataType(org.apache.iotdb.tsfile.file.metadata.enums.TSDataType dataType)
-
getDataType
public org.apache.iotdb.tsfile.file.metadata.enums.TSDataType getDataType()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
serialize
public static void serialize(ResultColumn resultColumn, java.nio.ByteBuffer byteBuffer)
-
deserialize
public static ResultColumn deserialize(java.nio.ByteBuffer byteBuffer)
-
-