Class ResultColumn


  • public class ResultColumn
    extends java.lang.Object
    ResultColumn is 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))]
    • 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 clause
        resultColumns - used to collect the result columns
        needAliasCheck - 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 from expression and apply slimit & soffset control
        resultColumns - used to collect the result columns
        needAliasCheck - 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:
        toString in class java.lang.Object
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public final boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • serialize

        public static void serialize​(ResultColumn resultColumn,
                                     java.nio.ByteBuffer byteBuffer)
      • deserialize

        public static ResultColumn deserialize​(java.nio.ByteBuffer byteBuffer)