Package org.apache.calcite.util
Class RelToSqlConverterUtil
java.lang.Object
org.apache.calcite.util.RelToSqlConverterUtil
Utilities used by multiple dialect for RelToSql conversion.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA ClickHouseSqlArrayTypeNameSpec to parse or unparse SQL ARRAY type toArray(VARCHAR).static classClickHouseSqlMapTypeNameSpec to parse or unparse SQL MAP type toMap(VARCHAR, VARCHAR). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SqlCharStringLiteralcreateRegexPatternLiteral(SqlNode call, SqlLiteral trimFlag) Creates regex pattern based on the TRIM flag.static SqlDataTypeSpecgetCastSpecAngleBracketArrayType(SqlDialect dialect, RelDataType type, SqlParserPos pos) Transformation ARRAY type fromVARCHAR ARRAYtoArray<VARCHAR>.static SqlDataTypeSpecgetCastSpecClickHouseSqlArrayType(SqlDialect dialect, RelDataType type, SqlParserPos pos) Transformation Map type fromVARCHAR ARRAYtoArray(VARCHAR).static SqlDataTypeSpecgetCastSpecClickHouseSqlMapType(SqlDialect dialect, RelDataType type, SqlParserPos pos) Transformation Map type fromMAP<VARCHAR,VARCHAR>toMap(VARCHAR,VARCHAR).static SqlSpecialOperatorspecialOperatorByName(String opName) Returns aSqlSpecialOperatorwith given operator name, mainly used for unparse override.static voidunparseBoolLiteralToCondition(SqlWriter writer, boolean value) Writes TRUE/FALSE or 1 = 1/ 1 < > 1 for certain.static voidunparseHiveTrim(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) For usage of TRIM, LTRIM and RTRIM in Hive, see Hive UDF usage.static RexNodeunparseIsTrueOrFalse(RexNode rexNode) Unparses IS TRUE,IS FALSE,IS NOT TRUE and IS NOT FALSE.static voidunparseSparkArrayAndMap(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) Unparses Array and Map value constructor.static voidunparseTrimLR(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.
-
Constructor Details
-
RelToSqlConverterUtil
public RelToSqlConverterUtil()
-
-
Method Details
-
unparseHiveTrim
For usage of TRIM, LTRIM and RTRIM in Hive, see Hive UDF usage. -
unparseTrimLR
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
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- writercall- the call
-
createRegexPatternLiteral
Creates regex pattern based on the TRIM flag.- Parameters:
call- SqlCall contains the values that need to be trimmedtrimFlag- the trimFlag, either BOTH, LEADING or TRAILING- Returns:
- the regex pattern of the character to be trimmed
-
specialOperatorByName
Returns aSqlSpecialOperatorwith given operator name, mainly used for unparse override. -
unparseBoolLiteralToCondition
Writes TRUE/FALSE or 1 = 1/ 1 < > 1 for certain.- Parameters:
writer- current SqlWriter objectvalue- boolean value to be unparsed.
-
getCastSpecClickHouseSqlMapType
public static SqlDataTypeSpec getCastSpecClickHouseSqlMapType(SqlDialect dialect, RelDataType type, SqlParserPos pos) Transformation Map type fromMAP<VARCHAR,VARCHAR>toMap(VARCHAR,VARCHAR). -
getCastSpecClickHouseSqlArrayType
public static SqlDataTypeSpec getCastSpecClickHouseSqlArrayType(SqlDialect dialect, RelDataType type, SqlParserPos pos) Transformation Map type fromVARCHAR ARRAYtoArray(VARCHAR). -
getCastSpecAngleBracketArrayType
public static SqlDataTypeSpec getCastSpecAngleBracketArrayType(SqlDialect dialect, RelDataType type, SqlParserPos pos) Transformation ARRAY type fromVARCHAR ARRAYtoArray<VARCHAR>.
-