Class RelToSqlConverterUtil

java.lang.Object
org.apache.calcite.util.RelToSqlConverterUtil

public abstract class RelToSqlConverterUtil extends Object
Utilities used by multiple dialect for RelToSql conversion.
  • Constructor Details

    • RelToSqlConverterUtil

      public RelToSqlConverterUtil()
  • Method Details

    • unparseHiveTrim

      public static void unparseHiveTrim(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
      For usage of TRIM, LTRIM and RTRIM in Hive, see Hive UDF usage.
    • unparseTrimLR

      public static void unparseTrimLR(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
      For usage of TRIM(LEADING 'A' FROM 'ABCA') convert to TRIM, LTRIM and RTRIM, can refer to BigQuery and Presto documents: BigQuery Trim Function, Presto Trim Function.
    • unparseIsTrueOrFalse

      public static RexNode unparseIsTrueOrFalse(RexNode rexNode)
      Unparses IS TRUE,IS FALSE,IS NOT TRUE and IS NOT FALSE.

      For example :

       A IS TRUE → A IS NOT NUL AND A
       A IS FALSE → A IS NOT NUL AND NOT A
       A IS NOT TRUE → A IS NUL OR NOT A
       A IS NOT FALSE → A IS NUL OR A
      
       an exception will be thrown when A is a non-deterministic function such as RAND_INTEGER.
       
      Parameters:
      rexNode - rexNode
    • unparseSparkArrayAndMap

      public static void unparseSparkArrayAndMap(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
      Unparses Array and Map value constructor.

      For example :

       SELECT ARRAY[1, 2, 3] → SELECT ARRAY (1, 2, 3)
       SELECT MAP['k1', 'v1', 'k2', 'v2'] → SELECT MAP ('k1', 'v1', 'k2', 'v2')
       
      Parameters:
      writer - writer
      call - the call
    • createRegexPatternLiteral

      public static SqlCharStringLiteral createRegexPatternLiteral(SqlNode call, SqlLiteral trimFlag)
      Creates regex pattern based on the TRIM flag.
      Parameters:
      call - SqlCall contains the values that need to be trimmed
      trimFlag - the trimFlag, either BOTH, LEADING or TRAILING
      Returns:
      the regex pattern of the character to be trimmed
    • specialOperatorByName

      public static SqlSpecialOperator specialOperatorByName(String opName)
      Returns a SqlSpecialOperator with given operator name, mainly used for unparse override.
    • unparseBoolLiteralToCondition

      public static void unparseBoolLiteralToCondition(SqlWriter writer, boolean value)
      Writes TRUE/FALSE or 1 = 1/ 1 < > 1 for certain.
      Parameters:
      writer - current SqlWriter object
      value - boolean value to be unparsed.