17 package com.mapd.calcite.parser;
21 import static org.apache.calcite.util.Static.RESOURCE;
23 import com.google.common.base.Predicate;
24 import com.google.common.collect.ImmutableList;
25 import com.google.common.collect.Multimap;
30 import org.apache.calcite.rel.metadata.RelColumnMapping;
31 import org.apache.calcite.rel.type.RelDataType;
32 import org.apache.calcite.rel.type.RelDataTypeFactory;
33 import org.apache.calcite.rel.type.RelDataTypeFactory.FieldInfoBuilder;
34 import org.apache.calcite.rel.type.RelDataTypeFamily;
35 import org.apache.calcite.schema.FunctionParameter;
36 import org.apache.calcite.schema.TranslatableTable;
37 import org.apache.calcite.sql.SqlAggFunction;
38 import org.apache.calcite.sql.SqlCall;
39 import org.apache.calcite.sql.SqlCallBinding;
40 import org.apache.calcite.sql.SqlDynamicParam;
41 import org.apache.calcite.sql.SqlFunction;
42 import org.apache.calcite.sql.SqlFunctionCategory;
43 import org.apache.calcite.sql.SqlIdentifier;
44 import org.apache.calcite.sql.SqlIntervalQualifier;
45 import org.apache.calcite.sql.SqlKind;
46 import org.apache.calcite.sql.SqlLiteral;
47 import org.apache.calcite.sql.SqlNode;
48 import org.apache.calcite.sql.SqlOperandCountRange;
50 import org.apache.calcite.sql.SqlOperatorBinding;
51 import org.apache.calcite.sql.SqlOperatorTable;
52 import org.apache.calcite.sql.SqlSyntax;
53 import org.apache.calcite.sql.SqlTableFunction;
54 import org.apache.calcite.sql.SqlUtil;
55 import org.apache.calcite.sql.SqlWriter;
56 import org.apache.calcite.sql.fun.SqlArrayValueConstructor;
57 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
58 import org.apache.calcite.sql.parser.SqlParserPos;
59 import org.apache.calcite.sql.type.ArraySqlType;
60 import org.apache.calcite.sql.type.InferTypes;
61 import org.apache.calcite.sql.type.OperandTypes;
62 import org.apache.calcite.sql.type.ReturnTypes;
63 import org.apache.calcite.sql.type.SameOperandTypeChecker;
64 import org.apache.calcite.sql.type.SqlOperandCountRanges;
65 import org.apache.calcite.sql.type.SqlReturnTypeInference;
66 import org.apache.calcite.sql.type.SqlTypeFamily;
67 import org.apache.calcite.sql.type.SqlTypeName;
68 import org.apache.calcite.sql.type.SqlTypeTransforms;
69 import org.apache.calcite.sql.type.SqlTypeUtil;
70 import org.apache.calcite.sql.util.ChainedSqlOperatorTable;
71 import org.apache.calcite.sql.util.ListSqlOperatorTable;
72 import org.apache.calcite.sql.util.ReflectiveSqlOperatorTable;
73 import org.apache.calcite.sql.validate.SqlNameMatcher;
75 import org.apache.calcite.util.Optionality;
76 import org.checkerframework.checker.nullness.qual.Nullable;
77 import org.slf4j.Logger;
78 import org.slf4j.LoggerFactory;
80 import java.lang.reflect.Field;
81 import java.util.Arrays;
82 import java.util.HashSet;
83 import java.util.Iterator;
84 import java.util.List;
85 import java.util.Locale;
88 import java.util.stream.Collectors;
93 SqlFunctionCategory category,
95 List<SqlOperator> operatorList,
96 SqlNameMatcher nameMatcher) {
97 for (
SqlOperator operator : this.getOperatorList()) {
98 if (
operator.getSyntax() != syntax) {
101 if (!opName.isSimple()
102 || !nameMatcher.matches(operator.getName(), opName.getSimple())) {
105 SqlFunctionCategory functionCategory;
106 if (
operator instanceof SqlFunction) {
107 functionCategory = ((SqlFunction)
operator).getFunctionType();
109 functionCategory = SqlFunctionCategory.SYSTEM;
111 if (category != functionCategory
112 && category != SqlFunctionCategory.USER_DEFINED_FUNCTION) {
115 operatorList.add(
operator);
129 Field
f = ReflectiveSqlOperatorTable.class.getDeclaredField(
130 "caseSensitiveOperators");
131 f.setAccessible(
true);
132 Multimap operators = (Multimap) f.get(SqlStdOperatorTable.instance());
133 for (Iterator i = operators.entries().iterator(); i.hasNext();) {
134 Map.Entry entry = (Map.Entry) i.next();
135 if (entry.getValue() == SqlStdOperatorTable.APPROX_COUNT_DISTINCT
136 || entry.getValue() == SqlStdOperatorTable.AVG
137 || entry.getValue() == SqlStdOperatorTable.ARRAY_VALUE_CONSTRUCTOR) {
144 Field f = ReflectiveSqlOperatorTable.class.getDeclaredField(
145 "caseInsensitiveOperators");
146 f.setAccessible(
true);
147 Multimap operators = (Multimap) f.get(SqlStdOperatorTable.instance());
148 for (Iterator i = operators.entries().iterator(); i.hasNext();) {
149 Map.Entry entry = (Map.Entry) i.next();
150 if (entry.getValue() == SqlStdOperatorTable.APPROX_COUNT_DISTINCT
151 || entry.getValue() == SqlStdOperatorTable.AVG
152 || entry.getValue() == SqlStdOperatorTable.ARRAY_VALUE_CONSTRUCTOR) {
160 }
catch (Exception e) {
161 throw new RuntimeException(e);
169 LoggerFactory.getLogger(HeavyDBSqlOperatorTable.class);
181 listOpTab = (ListSqlOperatorTable) tableList.get(1);
193 public void addUDF(
final Map<String, ExtensionFunction> extSigs) {
307 if (extSigs == null) {
310 HashSet<String> demangledNames =
new HashSet<String>();
312 final String demangledName =
dropSuffix(extSig.getKey());
313 final String demangledNameArity = extSig.getValue().isTableUdf()
314 ? String.format(
"%s-%s-%s",
316 extSig.getValue().getArgs(),
317 extSig.getValue().getCursorFieldTypes())
318 : String.format(
"%s-%d", demangledName, extSig.getValue().getArgs().size());
319 if (demangledNames.contains(demangledNameArity)) {
322 demangledNames.add(demangledNameArity);
323 if (extSig.getValue().isRowUdf()) {
332 int suffix_idx = str.indexOf(
"__");
333 if (suffix_idx == -1) {
336 assert suffix_idx > 0;
337 return str.substring(0, suffix_idx);
347 extends SqlArrayValueConstructor {
350 RelDataTypeFactory typeFactory, List<RelDataType> argTypes) {
351 if (argTypes.isEmpty()) {
352 return typeFactory.createSqlType(SqlTypeName.NULL);
354 return super.getComponentType(typeFactory, argTypes);
359 if (callBinding.operands().isEmpty()) {
362 return super.checkOperandTypes(callBinding, throwOnFailure);
372 SqlKind.OTHER_FUNCTION,
375 OperandTypes.NUMERIC,
376 SqlFunctionCategory.USER_DEFINED_FUNCTION);
381 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
382 return typeFactory.builder().add(
"I", SqlTypeName.INTEGER).build();
392 SqlKind.OTHER_FUNCTION,
395 OperandTypes.VARIADIC,
396 SqlFunctionCategory.USER_DEFINED_FUNCTION);
401 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
402 return typeFactory.builder().add(
"NAME", SqlTypeName.VARCHAR, 1024).build();
413 SqlKind.OTHER_FUNCTION,
416 OperandTypes.STRING_STRING,
417 SqlFunctionCategory.SYSTEM);
422 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
423 return typeFactory.createSqlType(SqlTypeName.BIGINT);
431 SqlKind.OTHER_FUNCTION,
435 SqlFunctionCategory.SYSTEM);
440 assert opBinding.getOperandCount() == 1;
441 RelDataType elem_type = opBinding.getOperandType(0).getComponentType();
442 assert elem_type != null;
448 public static class Any extends SqlFunction {
451 SqlKind.OTHER_FUNCTION,
455 SqlFunctionCategory.SYSTEM);
460 assert opBinding.getOperandCount() == 1;
461 RelDataType elem_type = opBinding.getOperandType(0).getComponentType();
462 assert elem_type != null;
468 public static class All extends SqlFunction {
471 SqlKind.OTHER_FUNCTION,
475 SqlFunctionCategory.SYSTEM);
480 assert opBinding.getOperandCount() == 1;
481 RelDataType elem_type = opBinding.getOperandType(0).getComponentType();
482 assert elem_type != null;
488 public static class Now extends SqlFunction {
491 SqlKind.OTHER_FUNCTION,
494 OperandTypes.NILADIC,
495 SqlFunctionCategory.SYSTEM);
500 assert opBinding.getOperandCount() == 0;
501 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
502 return typeFactory.createSqlType(SqlTypeName.TIMESTAMP);
510 SqlKind.OTHER_FUNCTION,
514 SqlFunctionCategory.SYSTEM);
519 assert opBinding.getOperandCount() == 1;
520 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
521 return typeFactory.createSqlType(
522 SqlTypeName.TIMESTAMP, opBinding.getOperandType(0).getPrecision());
530 SqlKind.OTHER_FUNCTION,
533 OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.DATETIME),
534 SqlFunctionCategory.SYSTEM);
539 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
540 return typeFactory.createTypeWithNullability(
541 typeFactory.createSqlType(SqlTypeName.BIGINT),
542 opBinding.getOperandType(1).isNullable());
549 SqlKind.OTHER_FUNCTION,
552 OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.DATETIME),
553 SqlFunctionCategory.TIMEDATE);
558 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
559 return typeFactory.createTypeWithNullability(
560 typeFactory.createSqlType(SqlTypeName.BIGINT),
561 opBinding.getOperandType(1).isNullable());
565 public static class Dateadd extends SqlFunction {
568 SqlKind.OTHER_FUNCTION,
571 OperandTypes.family(SqlTypeFamily.STRING,
572 SqlTypeFamily.INTEGER,
573 SqlTypeFamily.DATETIME),
574 SqlFunctionCategory.TIMEDATE);
579 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
580 return typeFactory.createTypeWithNullability(
581 typeFactory.createSqlType(
582 SqlTypeName.TIMESTAMP, opBinding.getOperandType(2).getPrecision()),
583 opBinding.getOperandType(2).isNullable());
590 SqlKind.OTHER_FUNCTION,
593 OperandTypes.family(SqlTypeFamily.STRING,
594 SqlTypeFamily.DATETIME,
595 SqlTypeFamily.DATETIME),
596 SqlFunctionCategory.TIMEDATE);
601 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
602 return typeFactory.createTypeWithNullability(
603 typeFactory.createSqlType(SqlTypeName.BIGINT),
604 opBinding.getOperandType(1).isNullable()
605 || opBinding.getOperandType(2).isNullable());
612 super(
"PG_DATE_TRUNC",
613 SqlKind.OTHER_FUNCTION,
616 OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.DATETIME),
617 SqlFunctionCategory.SYSTEM);
622 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
623 return typeFactory.createTypeWithNullability(
624 typeFactory.createSqlType(
625 SqlTypeName.TIMESTAMP, opBinding.getOperandType(1).getPrecision()),
626 opBinding.getOperandType(1).isNullable());
630 public static class Length extends SqlFunction {
633 SqlKind.OTHER_FUNCTION,
637 SqlFunctionCategory.SYSTEM);
642 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
643 return typeFactory.createSqlType(SqlTypeName.INTEGER);
650 SqlKind.OTHER_FUNCTION,
654 SqlFunctionCategory.SYSTEM);
659 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
660 return typeFactory.createSqlType(SqlTypeName.INTEGER);
666 super(
"KEY_FOR_STRING",
667 SqlKind.OTHER_FUNCTION,
671 SqlFunctionCategory.SYSTEM);
676 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
677 return typeFactory.createTypeWithNullability(
678 typeFactory.createSqlType(SqlTypeName.INTEGER),
679 opBinding.getOperandType(0).isNullable());
685 super(
"SAMPLE_RATIO",
686 SqlKind.OTHER_FUNCTION,
690 SqlFunctionCategory.SYSTEM);
695 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
696 return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
699 private static java.util.List<SqlTypeFamily>
signature() {
700 java.util.ArrayList<SqlTypeFamily> families =
701 new java.util.ArrayList<SqlTypeFamily>();
702 families.add(SqlTypeFamily.NUMERIC);
709 super(
"WIDTH_BUCKET",
710 SqlKind.OTHER_FUNCTION,
714 SqlFunctionCategory.SYSTEM);
719 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
720 return typeFactory.createTypeWithNullability(
721 typeFactory.createSqlType(SqlTypeName.INTEGER),
true);
724 private static java.util.List<SqlTypeFamily>
signature() {
725 java.util.ArrayList<SqlTypeFamily> families =
726 new java.util.ArrayList<SqlTypeFamily>();
727 families.add(SqlTypeFamily.NUMERIC);
728 families.add(SqlTypeFamily.NUMERIC);
729 families.add(SqlTypeFamily.NUMERIC);
730 families.add(SqlTypeFamily.INTEGER);
737 super(
"LEAD_IN_FRAME", SqlKind.LEAD);
743 super(
"LAG_IN_FRAME", SqlKind.LAG);
749 super(
"NTH_VALUE_IN_FRAME");
755 super(
"ARRAY_LENGTH",
756 SqlKind.OTHER_FUNCTION,
760 SqlFunctionCategory.SYSTEM);
765 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
766 return typeFactory.createSqlType(SqlTypeName.INTEGER);
770 public static class PgILike extends SqlFunction {
773 SqlKind.OTHER_FUNCTION,
777 SqlFunctionCategory.SYSTEM);
781 java.util.ArrayList<SqlTypeFamily> families =
782 new java.util.ArrayList<SqlTypeFamily>();
790 implements java.util.function.Predicate<Integer>, Predicate<Integer> {
792 public boolean test(Integer t) {
804 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
805 return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
812 SqlKind.OTHER_FUNCTION,
816 SqlFunctionCategory.SYSTEM);
820 java.util.ArrayList<SqlTypeFamily> families =
821 new java.util.ArrayList<SqlTypeFamily>();
829 implements java.util.function.Predicate<Integer>, Predicate<Integer> {
831 public boolean test(Integer t) {
842 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
843 return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
851 ReturnTypes.ARG0.andThen(SqlTypeTransforms.TO_NULLABLE)
852 .andThen(SqlTypeTransforms.TO_VARYING),
855 OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.STRING),
856 new SameOperandTypeChecker(2) {
858 protected List<Integer> getOperandList(
int operandCount) {
859 return ImmutableList.of(0, 1);
862 SqlFunctionCategory.STRING);
866 public SqlCall
createCall(@Nullable SqlLiteral functionQualifier,
868 @Nullable SqlNode... operands) {
869 assert functionQualifier == null;
870 switch (operands.length) {
872 operands =
new SqlNode[] {operands[0], SqlLiteral.createCharString(
" ", pos)};
875 if (operands[1] == null) {
876 operands[1] = SqlLiteral.createCharString(
" ", pos);
878 operands =
new SqlNode[] {operands[0], operands[1]};
881 throw new IllegalArgumentException(
882 "Invalid operand count " + Arrays.toString(operands));
884 return super.createCall(functionQualifier, pos, operands);
890 return (operands.size() == 1);
896 super(
"LTRIM", SqlKind.LTRIM);
901 super(
"RTRIM", SqlKind.RTRIM);
907 SqlKind.OTHER_FUNCTION,
908 ReturnTypes.ARG0.andThen(SqlTypeTransforms.TO_NULLABLE)
909 .andThen(SqlTypeTransforms.TO_VARYING),
911 OperandTypes.and(OperandTypes.family(SqlTypeFamily.STRING,
912 SqlTypeFamily.INTEGER,
913 SqlTypeFamily.STRING),
914 new SameOperandTypeChecker(3) {
916 protected List<Integer> getOperandList(
int operandCount) {
917 return ImmutableList.of(0, 2);
920 SqlFunctionCategory.STRING);
924 public SqlCall
createCall(@Nullable SqlLiteral functionQualifier,
926 @Nullable SqlNode... operands) {
927 assert functionQualifier == null;
928 switch (operands.length) {
930 operands =
new SqlNode[] {
931 operands[0], operands[1], SqlLiteral.createCharString(
" ", pos)};
934 if (operands[2] == null) {
935 operands[2] = SqlLiteral.createCharString(
" ", pos);
937 operands =
new SqlNode[] {operands[0], operands[1], operands[2]};
940 throw new IllegalArgumentException(
941 "Invalid operand count " + Arrays.toString(operands));
943 return super.createCall(functionQualifier, pos, operands);
948 if (!super.checkOperandTypes(callBinding, throwOnFailure)) {
953 return SqlTypeUtil.isCharTypeComparable(callBinding,
954 ImmutableList.of(callBinding.operand(0), callBinding.operand(2)),
964 return (operands.size() == 2);
982 SqlKind.OTHER_FUNCTION,
985 OperandTypes.family(getSignatureFamilies()),
990 java.util.ArrayList<SqlTypeFamily> families =
991 new java.util.ArrayList<SqlTypeFamily>();
994 families.add(SqlTypeFamily.INTEGER);
1000 return opBinding.getOperandType(0);
1007 SqlKind.OTHER_FUNCTION,
1010 OperandTypes.family(getSignatureFamilies()),
1015 java.util.ArrayList<SqlTypeFamily> families =
1016 new java.util.ArrayList<SqlTypeFamily>();
1025 return opBinding.getOperandType(0);
1029 public SqlCall
createCall(@Nullable SqlLiteral functionQualifier,
1031 @Nullable SqlNode... operands) {
1032 assert functionQualifier == null;
1033 switch (operands.length) {
1035 operands =
new SqlNode[] {
1036 operands[0], operands[1], SqlLiteral.createCharString(
"", pos)};
1041 throw new IllegalArgumentException(
1042 "Invalid operand count " + Arrays.toString(operands));
1044 return super.createCall(functionQualifier, pos, operands);
1050 return (operands.size() == 2);
1056 SqlKind.OTHER_FUNCTION,
1059 OperandTypes.family(getSignatureFamilies()),
1064 java.util.ArrayList<SqlTypeFamily> families =
1065 new java.util.ArrayList<SqlTypeFamily>();
1072 return opBinding.getOperandType(0);
1075 public static class Repeat extends SqlFunction {
1078 SqlKind.OTHER_FUNCTION,
1081 OperandTypes.family(getSignatureFamilies()),
1086 java.util.ArrayList<SqlTypeFamily> families =
1087 new java.util.ArrayList<SqlTypeFamily>();
1089 families.add(SqlTypeFamily.INTEGER);
1095 return opBinding.getOperandType(0);
1101 super(
"REGEXP_REPLACE",
1102 SqlKind.OTHER_FUNCTION,
1105 OperandTypes.family(getSignatureFamilies()),
1110 java.util.ArrayList<SqlTypeFamily> families =
1111 new java.util.ArrayList<SqlTypeFamily>();
1115 families.add(SqlTypeFamily.INTEGER);
1116 families.add(SqlTypeFamily.INTEGER);
1122 public SqlCall
createCall(@Nullable SqlLiteral functionQualifier,
1124 @Nullable SqlNode... operands) {
1125 assert functionQualifier == null;
1126 final int num_operands = operands.length;
1127 if (num_operands < 2 || num_operands > 6) {
1128 throw new IllegalArgumentException(
1129 "Invalid operand count " + Arrays.toString(operands));
1131 SqlNode[] new_operands =
new SqlNode[6];
1133 new_operands[0] = operands[0];
1135 new_operands[1] = operands[1];
1137 if (num_operands < 3 || operands[2] == null) {
1138 new_operands[2] = SqlLiteral.createCharString(
"", pos);
1140 new_operands[2] = operands[2];
1143 if (num_operands < 4 || operands[3] == null) {
1144 new_operands[3] = SqlLiteral.createExactNumeric(
"1", pos);
1146 new_operands[3] = operands[3];
1149 if (num_operands < 5 || operands[4] == null) {
1150 new_operands[4] = SqlLiteral.createExactNumeric(
"0", pos);
1152 new_operands[4] = operands[4];
1155 if (num_operands < 6 || operands[5] == null) {
1156 new_operands[5] = SqlLiteral.createCharString(
"c", pos);
1158 new_operands[5] = operands[5];
1160 return super.createCall(functionQualifier, pos, new_operands);
1165 return opBinding.getOperandType(0);
1171 super(
"REGEXP_SUBSTR",
1172 SqlKind.OTHER_FUNCTION,
1175 OperandTypes.family(getSignatureFamilies()),
1181 SqlKind.OTHER_FUNCTION,
1184 OperandTypes.family(getSignatureFamilies()),
1185 SqlFunctionCategory.SYSTEM);
1189 java.util.ArrayList<SqlTypeFamily> families =
1190 new java.util.ArrayList<SqlTypeFamily>();
1193 families.add(SqlTypeFamily.INTEGER);
1194 families.add(SqlTypeFamily.INTEGER);
1196 families.add(SqlTypeFamily.INTEGER);
1201 public SqlCall
createCall(@Nullable SqlLiteral functionQualifier,
1203 @Nullable SqlNode... operands) {
1204 assert functionQualifier == null;
1205 final int num_operands = operands.length;
1206 if (num_operands < 2 || num_operands > 6) {
1207 throw new IllegalArgumentException(
1208 "Invalid operand count " + Arrays.toString(operands));
1210 SqlNode[] new_operands =
new SqlNode[6];
1213 new_operands[0] = operands[0];
1215 new_operands[1] = operands[1];
1217 if (num_operands < 3 || operands[2] == null) {
1218 new_operands[2] = SqlLiteral.createExactNumeric(
"1", pos);
1220 new_operands[2] = operands[2];
1223 if (num_operands < 4 || operands[3] == null) {
1224 new_operands[3] = SqlLiteral.createExactNumeric(
"1", pos);
1226 new_operands[3] = operands[3];
1229 if (num_operands < 5 || operands[4] == null) {
1230 new_operands[4] = SqlLiteral.createCharString(
"c", pos);
1232 new_operands[4] = operands[4];
1235 if (num_operands < 6 || operands[5] == null) {
1236 new_operands[5] = SqlLiteral.createExactNumeric(
"1", pos);
1238 new_operands[5] = operands[5];
1240 return super.createCall(functionQualifier, pos, new_operands);
1245 return opBinding.getOperandType(0);
1251 super(
"REGEXP_MATCH");
1256 super(
"BASE64_ENCODE",
1257 SqlKind.OTHER_FUNCTION,
1260 OperandTypes.family(getSignatureFamilies()),
1265 java.util.ArrayList<SqlTypeFamily> families =
1266 new java.util.ArrayList<SqlTypeFamily>();
1273 return opBinding.getOperandType(0);
1279 super(
"BASE64_DECODE",
1280 SqlKind.OTHER_FUNCTION,
1283 OperandTypes.family(getSignatureFamilies()),
1288 java.util.ArrayList<SqlTypeFamily> families =
1289 new java.util.ArrayList<SqlTypeFamily>();
1296 return opBinding.getOperandType(0);
1305 SqlKind.OTHER_FUNCTION,
1307 InferTypes.FIRST_KNOWN,
1309 SqlFunctionCategory.SYSTEM);
1315 assert opBinding.getOperandCount() == 2;
1316 RelDataType ret = opBinding.getOperandType(1);
1317 RelDataType firstType = opBinding.getOperandType(0);
1318 ret = opBinding.getTypeFactory().createTypeWithNullability(
1319 ret, firstType.isNullable());
1320 if (opBinding instanceof SqlCallBinding) {
1321 SqlCallBinding callBinding = (SqlCallBinding) opBinding;
1322 SqlNode operand0 = callBinding.operand(0);
1326 if (((operand0 instanceof SqlLiteral)
1327 && (((SqlLiteral) operand0).getValue() == null))
1328 || (operand0 instanceof SqlDynamicParam)) {
1331 validator.setValidatedNodeType(operand0, ret);
1338 assert operandsCount == 2;
1339 return "{0}({1} AS {2})";
1343 return SqlOperandCountRanges.of(2);
1352 final SqlNode left = callBinding.operand(0);
1353 final SqlNode right = callBinding.operand(1);
1354 if (SqlUtil.isNullLiteral(left,
false) || left instanceof SqlDynamicParam) {
1357 RelDataType validatedNodeType =
1358 callBinding.getValidator().getValidatedNodeType(left);
1359 RelDataType returnType =
1360 callBinding.getValidator().deriveType(callBinding.getScope(), right);
1361 if (!SqlTypeUtil.canCastFrom(returnType, validatedNodeType,
true)) {
1362 if (throwOnFailure) {
1363 throw callBinding.newError(RESOURCE.cannotCastValue(
1364 validatedNodeType.toString(), returnType.toString()));
1368 if (SqlTypeUtil.areCharacterSetsMismatched(validatedNodeType, returnType)) {
1369 if (throwOnFailure) {
1372 throw callBinding.newError(RESOURCE.cannotCastValue(
1373 validatedNodeType.getFullTypeString(), returnType.getFullTypeString()));
1381 return SqlSyntax.FUNCTION;
1384 public void unparse(SqlWriter writer, SqlCall call,
int leftPrec,
int rightPrec) {
1385 assert call.operandCount() == 2;
1386 final SqlWriter.Frame frame = writer.startFunCall(getName());
1387 call.operand(0).unparse(writer, 0, 0);
1389 if (call.operand(1) instanceof SqlIntervalQualifier) {
1390 writer.sep(
"INTERVAL");
1392 call.operand(1).unparse(writer, 0, 0);
1393 writer.endFunCall(frame);
1397 public static class Likely extends SqlFunction {
1400 SqlKind.OTHER_FUNCTION,
1403 OperandTypes.BOOLEAN,
1404 SqlFunctionCategory.SYSTEM);
1409 return opBinding.getOperandType(0);
1416 SqlKind.OTHER_FUNCTION,
1419 OperandTypes.BOOLEAN,
1420 SqlFunctionCategory.SYSTEM);
1425 return opBinding.getOperandType(0);
1429 public static class Sign extends SqlFunction {
1432 SqlKind.OTHER_FUNCTION,
1435 OperandTypes.NUMERIC,
1436 SqlFunctionCategory.NUMERIC);
1441 return opBinding.getOperandType(0);
1448 SqlKind.OTHER_FUNCTION,
1451 OperandTypes.family(signature()),
1452 SqlFunctionCategory.NUMERIC);
1457 assert opBinding.getOperandCount() == 2;
1458 return opBinding.getOperandType(0);
1462 java.util.List<SqlTypeFamily> truncate_sig =
1463 new java.util.ArrayList<SqlTypeFamily>();
1464 truncate_sig.add(SqlTypeFamily.NUMERIC);
1465 truncate_sig.add(SqlTypeFamily.INTEGER);
1466 return truncate_sig;
1473 SqlKind.OTHER_FUNCTION,
1476 OperandTypes.family(signature()),
1477 SqlFunctionCategory.SYSTEM);
1482 assert opBinding.getOperandCount() == 1;
1483 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1484 return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
1488 java.util.List<SqlTypeFamily> st_isempty_sig =
1489 new java.util.ArrayList<SqlTypeFamily>();
1490 st_isempty_sig.add(SqlTypeFamily.ANY);
1491 return st_isempty_sig;
1498 SqlKind.OTHER_FUNCTION,
1501 OperandTypes.family(signature()),
1502 SqlFunctionCategory.SYSTEM);
1507 assert opBinding.getOperandCount() == 1;
1508 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1509 return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
1513 java.util.List<SqlTypeFamily> st_isvalid_sig =
1514 new java.util.ArrayList<SqlTypeFamily>();
1515 st_isvalid_sig.add(SqlTypeFamily.ANY);
1516 return st_isvalid_sig;
1522 super(
"ST_Contains",
1523 SqlKind.OTHER_FUNCTION,
1526 OperandTypes.family(signature()),
1527 SqlFunctionCategory.SYSTEM);
1532 assert opBinding.getOperandCount() == 2;
1533 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1534 return typeFactory.createTypeWithNullability(
1535 typeFactory.createSqlType(SqlTypeName.BOOLEAN),
1536 opBinding.getOperandType(0).isNullable()
1537 || opBinding.getOperandType(1).isNullable());
1541 java.util.List<SqlTypeFamily> st_contains_sig =
1542 new java.util.ArrayList<SqlTypeFamily>();
1543 st_contains_sig.add(SqlTypeFamily.ANY);
1544 st_contains_sig.add(SqlTypeFamily.ANY);
1545 return st_contains_sig;
1552 SqlKind.OTHER_FUNCTION,
1555 OperandTypes.family(signature()),
1556 SqlFunctionCategory.SYSTEM);
1561 assert opBinding.getOperandCount() == 2;
1562 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1563 return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
1567 java.util.List<SqlTypeFamily> st_equals_sig =
1568 new java.util.ArrayList<SqlTypeFamily>();
1569 st_equals_sig.add(SqlTypeFamily.ANY);
1570 st_equals_sig.add(SqlTypeFamily.ANY);
1571 return st_equals_sig;
1577 super(
"ST_Intersects",
1578 SqlKind.OTHER_FUNCTION,
1581 OperandTypes.family(signature()),
1582 SqlFunctionCategory.SYSTEM);
1587 assert opBinding.getOperandCount() == 2;
1588 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1589 return typeFactory.createTypeWithNullability(
1590 typeFactory.createSqlType(SqlTypeName.BOOLEAN),
1591 opBinding.getOperandType(0).isNullable()
1592 || opBinding.getOperandType(1).isNullable());
1596 java.util.List<SqlTypeFamily> st_intersects_sig =
1597 new java.util.ArrayList<SqlTypeFamily>();
1598 st_intersects_sig.add(SqlTypeFamily.ANY);
1599 st_intersects_sig.add(SqlTypeFamily.ANY);
1600 return st_intersects_sig;
1606 super(
"ST_Overlaps",
1607 SqlKind.OTHER_FUNCTION,
1610 OperandTypes.family(signature()),
1611 SqlFunctionCategory.SYSTEM);
1616 assert opBinding.getOperandCount() == 2;
1617 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1618 return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
1622 java.util.List<SqlTypeFamily> st_overlaps_sig =
1623 new java.util.ArrayList<SqlTypeFamily>();
1624 st_overlaps_sig.add(SqlTypeFamily.ANY);
1625 st_overlaps_sig.add(SqlTypeFamily.ANY);
1626 return st_overlaps_sig;
1632 super(
"ST_Approx_Overlaps",
1633 SqlKind.OTHER_FUNCTION,
1636 OperandTypes.family(signature()),
1637 SqlFunctionCategory.SYSTEM);
1642 assert opBinding.getOperandCount() == 2;
1643 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1644 return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
1648 java.util.List<SqlTypeFamily> st_overlaps_sig =
1649 new java.util.ArrayList<SqlTypeFamily>();
1650 st_overlaps_sig.add(SqlTypeFamily.ANY);
1651 st_overlaps_sig.add(SqlTypeFamily.ANY);
1652 return st_overlaps_sig;
1658 super(
"ST_Disjoint",
1659 SqlKind.OTHER_FUNCTION,
1662 OperandTypes.family(signature()),
1663 SqlFunctionCategory.SYSTEM);
1668 assert opBinding.getOperandCount() == 2;
1669 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1670 return typeFactory.createTypeWithNullability(
1671 typeFactory.createSqlType(SqlTypeName.BOOLEAN),
1672 opBinding.getOperandType(0).isNullable()
1673 || opBinding.getOperandType(1).isNullable());
1677 java.util.List<SqlTypeFamily> st_disjoint_sig =
1678 new java.util.ArrayList<SqlTypeFamily>();
1679 st_disjoint_sig.add(SqlTypeFamily.ANY);
1680 st_disjoint_sig.add(SqlTypeFamily.ANY);
1681 return st_disjoint_sig;
1688 SqlKind.OTHER_FUNCTION,
1691 OperandTypes.family(signature()),
1692 SqlFunctionCategory.SYSTEM);
1697 assert opBinding.getOperandCount() == 2;
1698 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1699 return typeFactory.createTypeWithNullability(
1700 typeFactory.createSqlType(SqlTypeName.BOOLEAN),
1701 opBinding.getOperandType(0).isNullable()
1702 || opBinding.getOperandType(1).isNullable());
1706 java.util.List<SqlTypeFamily> st_within_sig =
1707 new java.util.ArrayList<SqlTypeFamily>();
1708 st_within_sig.add(SqlTypeFamily.ANY);
1709 st_within_sig.add(SqlTypeFamily.ANY);
1710 return st_within_sig;
1717 SqlKind.OTHER_FUNCTION,
1720 OperandTypes.family(signature()),
1721 SqlFunctionCategory.SYSTEM);
1726 assert opBinding.getOperandCount() == 3;
1727 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1728 return typeFactory.createTypeWithNullability(
1729 typeFactory.createSqlType(SqlTypeName.BOOLEAN),
1730 opBinding.getOperandType(0).isNullable()
1731 || opBinding.getOperandType(1).isNullable()
1732 || opBinding.getOperandType(2).isNullable());
1736 java.util.List<SqlTypeFamily> st_dwithin_sig =
1737 new java.util.ArrayList<SqlTypeFamily>();
1738 st_dwithin_sig.add(SqlTypeFamily.ANY);
1739 st_dwithin_sig.add(SqlTypeFamily.ANY);
1740 st_dwithin_sig.add(SqlTypeFamily.NUMERIC);
1741 return st_dwithin_sig;
1747 super(
"ST_DFullyWithin",
1748 SqlKind.OTHER_FUNCTION,
1751 OperandTypes.family(signature()),
1752 SqlFunctionCategory.SYSTEM);
1757 assert opBinding.getOperandCount() == 3;
1758 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1759 return typeFactory.createTypeWithNullability(
1760 typeFactory.createSqlType(SqlTypeName.BOOLEAN),
1761 opBinding.getOperandType(0).isNullable()
1762 || opBinding.getOperandType(1).isNullable()
1763 || opBinding.getOperandType(2).isNullable());
1767 java.util.List<SqlTypeFamily> st_dwithin_sig =
1768 new java.util.ArrayList<SqlTypeFamily>();
1769 st_dwithin_sig.add(SqlTypeFamily.ANY);
1770 st_dwithin_sig.add(SqlTypeFamily.ANY);
1771 st_dwithin_sig.add(SqlTypeFamily.NUMERIC);
1772 return st_dwithin_sig;
1778 super(
"ST_Distance",
1779 SqlKind.OTHER_FUNCTION,
1782 OperandTypes.family(signature()),
1783 SqlFunctionCategory.SYSTEM);
1788 assert opBinding.getOperandCount() == 2;
1789 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1790 return typeFactory.createTypeWithNullability(
1791 typeFactory.createSqlType(SqlTypeName.DOUBLE),
1792 opBinding.getOperandType(0).isNullable()
1793 || opBinding.getOperandType(1).isNullable());
1797 java.util.List<SqlTypeFamily> st_distance_sig =
1798 new java.util.ArrayList<SqlTypeFamily>();
1799 st_distance_sig.add(SqlTypeFamily.ANY);
1800 st_distance_sig.add(SqlTypeFamily.ANY);
1801 return st_distance_sig;
1807 super(
"ST_MaxDistance",
1808 SqlKind.OTHER_FUNCTION,
1811 OperandTypes.family(signature()),
1812 SqlFunctionCategory.SYSTEM);
1817 assert opBinding.getOperandCount() == 2;
1818 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1819 return typeFactory.createTypeWithNullability(
1820 typeFactory.createSqlType(SqlTypeName.DOUBLE),
1821 opBinding.getOperandType(0).isNullable()
1822 || opBinding.getOperandType(1).isNullable());
1826 java.util.List<SqlTypeFamily> st_maxdistance_sig =
1827 new java.util.ArrayList<SqlTypeFamily>();
1828 st_maxdistance_sig.add(SqlTypeFamily.ANY);
1829 st_maxdistance_sig.add(SqlTypeFamily.ANY);
1830 return st_maxdistance_sig;
1836 super(
"ST_GeogFromText",
1837 SqlKind.OTHER_FUNCTION,
1840 OperandTypes.or(OperandTypes.family(SqlTypeFamily.ANY),
1841 OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER)),
1842 SqlFunctionCategory.SYSTEM);
1847 assert opBinding.getOperandCount() == 1;
1848 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1849 return typeFactory.createSqlType(SqlTypeName.INTEGER);
1855 super(
"ST_GeomFromText",
1856 SqlKind.OTHER_FUNCTION,
1859 OperandTypes.or(OperandTypes.family(SqlTypeFamily.ANY),
1860 OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER)),
1861 SqlFunctionCategory.SYSTEM);
1866 assert opBinding.getOperandCount() == 1;
1867 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1868 return typeFactory.createSqlType(SqlTypeName.INTEGER);
1874 super(
"ST_Transform",
1875 SqlKind.OTHER_FUNCTION,
1878 OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER),
1879 SqlFunctionCategory.SYSTEM);
1884 assert opBinding.getOperandCount() == 1;
1885 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1886 return typeFactory.createTypeWithNullability(
1887 typeFactory.createSqlType(SqlTypeName.INTEGER),
1888 opBinding.getOperandType(0).isNullable());
1892 static class ST_X extends SqlFunction {
1895 SqlKind.OTHER_FUNCTION,
1898 OperandTypes.family(SqlTypeFamily.ANY),
1899 SqlFunctionCategory.SYSTEM);
1904 assert opBinding.getOperandCount() == 1;
1905 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1906 return typeFactory.createTypeWithNullability(
1907 typeFactory.createSqlType(SqlTypeName.DOUBLE),
1908 opBinding.getOperandType(0).isNullable());
1912 static class ST_Y extends SqlFunction {
1915 SqlKind.OTHER_FUNCTION,
1918 OperandTypes.family(SqlTypeFamily.ANY),
1919 SqlFunctionCategory.SYSTEM);
1924 assert opBinding.getOperandCount() == 1;
1925 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1926 return typeFactory.createTypeWithNullability(
1927 typeFactory.createSqlType(SqlTypeName.DOUBLE),
1928 opBinding.getOperandType(0).isNullable());
1935 SqlKind.OTHER_FUNCTION,
1938 OperandTypes.family(SqlTypeFamily.ANY),
1939 SqlFunctionCategory.SYSTEM);
1944 assert opBinding.getOperandCount() == 1;
1945 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1946 return typeFactory.createTypeWithNullability(
1947 typeFactory.createSqlType(SqlTypeName.DOUBLE),
1948 opBinding.getOperandType(0).isNullable());
1955 SqlKind.OTHER_FUNCTION,
1958 OperandTypes.family(SqlTypeFamily.ANY),
1959 SqlFunctionCategory.SYSTEM);
1964 assert opBinding.getOperandCount() == 1;
1965 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1966 return typeFactory.createTypeWithNullability(
1967 typeFactory.createSqlType(SqlTypeName.DOUBLE),
1968 opBinding.getOperandType(0).isNullable());
1975 SqlKind.OTHER_FUNCTION,
1978 OperandTypes.family(SqlTypeFamily.ANY),
1979 SqlFunctionCategory.SYSTEM);
1984 assert opBinding.getOperandCount() == 1;
1985 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1986 return typeFactory.createTypeWithNullability(
1987 typeFactory.createSqlType(SqlTypeName.DOUBLE),
1988 opBinding.getOperandType(0).isNullable());
1995 SqlKind.OTHER_FUNCTION,
1998 OperandTypes.family(SqlTypeFamily.ANY),
1999 SqlFunctionCategory.SYSTEM);
2004 assert opBinding.getOperandCount() == 1;
2005 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2006 return typeFactory.createTypeWithNullability(
2007 typeFactory.createSqlType(SqlTypeName.DOUBLE),
2008 opBinding.getOperandType(0).isNullable());
2015 SqlKind.OTHER_FUNCTION,
2018 OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER),
2019 SqlFunctionCategory.SYSTEM);
2024 assert opBinding.getOperandCount() == 1;
2025 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2026 return typeFactory.createTypeWithNullability(
2027 typeFactory.createSqlType(SqlTypeName.INTEGER),
2028 opBinding.getOperandType(0).isNullable());
2034 super(
"ST_EndPoint",
2035 SqlKind.OTHER_FUNCTION,
2038 OperandTypes.family(SqlTypeFamily.ANY),
2039 SqlFunctionCategory.SYSTEM);
2044 assert opBinding.getOperandCount() == 1;
2045 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2046 return typeFactory.createTypeWithNullability(
2047 typeFactory.createSqlType(SqlTypeName.INTEGER),
2048 opBinding.getOperandType(0).isNullable());
2054 super(
"ST_StartPoint",
2055 SqlKind.OTHER_FUNCTION,
2058 OperandTypes.family(SqlTypeFamily.ANY),
2059 SqlFunctionCategory.SYSTEM);
2064 assert opBinding.getOperandCount() == 1;
2065 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2066 return typeFactory.createTypeWithNullability(
2067 typeFactory.createSqlType(SqlTypeName.INTEGER),
2068 opBinding.getOperandType(0).isNullable());
2075 SqlKind.OTHER_FUNCTION,
2078 OperandTypes.family(SqlTypeFamily.ANY),
2079 SqlFunctionCategory.SYSTEM);
2084 assert opBinding.getOperandCount() == 1;
2085 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2086 return typeFactory.createTypeWithNullability(
2087 typeFactory.createSqlType(SqlTypeName.DOUBLE),
2088 opBinding.getOperandType(0).isNullable());
2094 super(
"ST_Perimeter",
2095 SqlKind.OTHER_FUNCTION,
2098 OperandTypes.family(SqlTypeFamily.ANY),
2099 SqlFunctionCategory.SYSTEM);
2104 assert opBinding.getOperandCount() == 1;
2105 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2106 return typeFactory.createTypeWithNullability(
2107 typeFactory.createSqlType(SqlTypeName.DOUBLE),
2108 opBinding.getOperandType(0).isNullable());
2115 SqlKind.OTHER_FUNCTION,
2118 OperandTypes.family(SqlTypeFamily.ANY),
2119 SqlFunctionCategory.SYSTEM);
2124 assert opBinding.getOperandCount() == 1;
2125 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2126 return typeFactory.createTypeWithNullability(
2127 typeFactory.createSqlType(SqlTypeName.DOUBLE),
2128 opBinding.getOperandType(0).isNullable());
2135 SqlKind.OTHER_FUNCTION,
2138 OperandTypes.family(SqlTypeFamily.ANY),
2139 SqlFunctionCategory.SYSTEM);
2144 assert opBinding.getOperandCount() == 1;
2145 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2146 return typeFactory.createTypeWithNullability(
2147 typeFactory.createSqlType(SqlTypeName.INTEGER),
2148 opBinding.getOperandType(0).isNullable());
2155 SqlKind.OTHER_FUNCTION,
2158 OperandTypes.family(SqlTypeFamily.ANY),
2159 SqlFunctionCategory.SYSTEM);
2164 assert opBinding.getOperandCount() == 1;
2165 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2166 return typeFactory.createTypeWithNullability(
2167 typeFactory.createSqlType(SqlTypeName.INTEGER),
2168 opBinding.getOperandType(0).isNullable());
2174 super(
"ST_NumGeometries",
2175 SqlKind.OTHER_FUNCTION,
2178 OperandTypes.family(SqlTypeFamily.ANY),
2179 SqlFunctionCategory.SYSTEM);
2184 assert opBinding.getOperandCount() == 1;
2185 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2186 return typeFactory.createTypeWithNullability(
2187 typeFactory.createSqlType(SqlTypeName.INTEGER),
2188 opBinding.getOperandType(0).isNullable());
2195 SqlKind.OTHER_FUNCTION,
2198 OperandTypes.family(SqlTypeFamily.ANY),
2199 SqlFunctionCategory.SYSTEM);
2204 assert opBinding.getOperandCount() == 1;
2205 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2206 return typeFactory.createTypeWithNullability(
2207 typeFactory.createSqlType(SqlTypeName.INTEGER),
2208 opBinding.getOperandType(0).isNullable());
2215 SqlKind.OTHER_FUNCTION,
2218 OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER),
2219 SqlFunctionCategory.SYSTEM);
2224 assert opBinding.getOperandCount() == 1;
2225 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2226 return typeFactory.createTypeWithNullability(
2227 typeFactory.createSqlType(SqlTypeName.INTEGER),
2228 opBinding.getOperandType(0).isNullable());
2235 SqlKind.OTHER_FUNCTION,
2238 OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
2239 SqlFunctionCategory.SYSTEM);
2244 assert opBinding.getOperandCount() == 2;
2245 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2246 return typeFactory.createSqlType(SqlTypeName.INTEGER);
2252 super(
"ST_Centroid",
2253 SqlKind.OTHER_FUNCTION,
2256 OperandTypes.family(signature()),
2257 SqlFunctionCategory.SYSTEM);
2262 assert opBinding.getOperandCount() == 1;
2263 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2264 return typeFactory.createSqlType(SqlTypeName.INTEGER);
2268 java.util.List<SqlTypeFamily> st_centroid_sig =
2269 new java.util.ArrayList<SqlTypeFamily>();
2270 st_centroid_sig.add(SqlTypeFamily.ANY);
2271 return st_centroid_sig;
2278 SqlKind.OTHER_FUNCTION,
2281 OperandTypes.family(signature()),
2282 SqlFunctionCategory.SYSTEM);
2287 assert opBinding.getOperandCount() == 2;
2288 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2289 return typeFactory.createSqlType(SqlTypeName.INTEGER);
2293 java.util.List<SqlTypeFamily> st_buffer_sig =
2294 new java.util.ArrayList<SqlTypeFamily>();
2295 st_buffer_sig.add(SqlTypeFamily.ANY);
2296 st_buffer_sig.add(SqlTypeFamily.NUMERIC);
2297 return st_buffer_sig;
2303 super(
"ST_ConcaveHull",
2304 SqlKind.OTHER_FUNCTION,
2307 OperandTypes.family(signature()),
2308 SqlFunctionCategory.SYSTEM);
2313 assert opBinding.getOperandCount() == 2;
2314 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2315 return typeFactory.createSqlType(SqlTypeName.INTEGER);
2319 java.util.List<SqlTypeFamily> st_concavehull_sig =
2320 new java.util.ArrayList<SqlTypeFamily>();
2321 st_concavehull_sig.add(SqlTypeFamily.ANY);
2322 st_concavehull_sig.add(SqlTypeFamily.NUMERIC);
2323 return st_concavehull_sig;
2329 super(
"ST_ConvexHull",
2330 SqlKind.OTHER_FUNCTION,
2333 OperandTypes.family(signature()),
2334 SqlFunctionCategory.SYSTEM);
2339 assert opBinding.getOperandCount() == 1;
2340 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2341 return typeFactory.createSqlType(SqlTypeName.INTEGER);
2345 java.util.List<SqlTypeFamily> st_convexhull_sig =
2346 new java.util.ArrayList<SqlTypeFamily>();
2347 st_convexhull_sig.add(SqlTypeFamily.ANY);
2348 return st_convexhull_sig;
2354 super(
"ST_Intersection",
2355 SqlKind.OTHER_FUNCTION,
2358 OperandTypes.family(signature()),
2359 SqlFunctionCategory.SYSTEM);
2364 assert opBinding.getOperandCount() == 2;
2365 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2366 return typeFactory.createSqlType(SqlTypeName.INTEGER);
2370 java.util.List<SqlTypeFamily> st_intersection_sig =
2371 new java.util.ArrayList<SqlTypeFamily>();
2372 st_intersection_sig.add(SqlTypeFamily.ANY);
2373 st_intersection_sig.add(SqlTypeFamily.ANY);
2374 return st_intersection_sig;
2381 SqlKind.OTHER_FUNCTION,
2384 OperandTypes.family(signature()),
2385 SqlFunctionCategory.SYSTEM);
2390 assert opBinding.getOperandCount() == 2;
2391 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2392 return typeFactory.createSqlType(SqlTypeName.INTEGER);
2396 java.util.List<SqlTypeFamily> st_union_sig =
2397 new java.util.ArrayList<SqlTypeFamily>();
2398 st_union_sig.add(SqlTypeFamily.ANY);
2399 st_union_sig.add(SqlTypeFamily.ANY);
2400 return st_union_sig;
2406 super(
"ST_Difference",
2407 SqlKind.OTHER_FUNCTION,
2410 OperandTypes.family(signature()),
2411 SqlFunctionCategory.SYSTEM);
2416 assert opBinding.getOperandCount() == 2;
2417 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2418 return typeFactory.createSqlType(SqlTypeName.INTEGER);
2422 java.util.List<SqlTypeFamily> st_difference_sig =
2423 new java.util.ArrayList<SqlTypeFamily>();
2424 st_difference_sig.add(SqlTypeFamily.ANY);
2425 st_difference_sig.add(SqlTypeFamily.ANY);
2426 return st_difference_sig;
2432 super(
"CastToGeography",
2433 SqlKind.OTHER_FUNCTION,
2436 OperandTypes.family(SqlTypeFamily.ANY),
2437 SqlFunctionCategory.SYSTEM);
2442 assert opBinding.getOperandCount() == 1;
2443 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2444 return typeFactory.createSqlType(SqlTypeName.INTEGER);
2450 super(
"ENCODE_TEXT",
2451 SqlKind.OTHER_FUNCTION,
2454 OperandTypes.family(SqlTypeFamily.STRING),
2455 SqlFunctionCategory.SYSTEM);
2460 assert opBinding.getOperandCount() == 1;
2461 return opBinding.getOperandType(0);
2468 super(
"OFFSET_IN_FRAGMENT",
2469 SqlKind.OTHER_FUNCTION,
2472 OperandTypes.NILADIC,
2473 SqlFunctionCategory.SYSTEM);
2478 assert opBinding.getOperandCount() == 0;
2479 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2480 return typeFactory.createSqlType(SqlTypeName.BIGINT);
2486 super(
"APPROX_COUNT_DISTINCT",
2488 SqlKind.OTHER_FUNCTION,
2491 OperandTypes.or(OperandTypes.family(SqlTypeFamily.ANY),
2492 OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER)),
2493 SqlFunctionCategory.SYSTEM,
2496 Optionality.FORBIDDEN);
2501 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2502 return typeFactory.createSqlType(SqlTypeName.BIGINT);
2508 super(
"APPROX_MEDIAN",
2509 SqlKind.OTHER_FUNCTION,
2512 OperandTypes.family(SqlTypeFamily.NUMERIC),
2513 SqlFunctionCategory.SYSTEM);
2518 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2519 return typeFactory.createSqlType(SqlTypeName.DOUBLE);
2525 super(
"APPROX_PERCENTILE",
2526 SqlKind.OTHER_FUNCTION,
2529 OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
2530 SqlFunctionCategory.SYSTEM);
2535 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2536 return typeFactory.createSqlType(SqlTypeName.DOUBLE);
2542 super(
"APPROX_QUANTILE",
2543 SqlKind.OTHER_FUNCTION,
2546 OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
2547 SqlFunctionCategory.SYSTEM);
2552 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2553 return typeFactory.createSqlType(SqlTypeName.DOUBLE);
2561 SqlKind.OTHER_FUNCTION,
2564 OperandTypes.family(SqlTypeFamily.NUMERIC),
2565 SqlFunctionCategory.SYSTEM);
2570 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2571 return typeFactory.createSqlType(SqlTypeName.DOUBLE);
2575 static class Mode extends SqlAggFunction {
2578 SqlKind.OTHER_FUNCTION,
2582 SqlFunctionCategory.SYSTEM);
2587 return opBinding.getOperandType(0);
2591 public static class Sample extends SqlAggFunction {
2595 SqlKind.OTHER_FUNCTION,
2599 SqlFunctionCategory.SYSTEM,
2602 Optionality.FORBIDDEN);
2607 return opBinding.getOperandType(0);
2614 super(
"LAST_SAMPLE",
2616 SqlKind.OTHER_FUNCTION,
2620 SqlFunctionCategory.SYSTEM,
2623 Optionality.FORBIDDEN);
2628 return opBinding.getOperandType(0);
2636 SqlKind.OTHER_FUNCTION,
2640 SqlFunctionCategory.SYSTEM,
2643 Optionality.FORBIDDEN);
2648 return opBinding.getOperandType(0);
2652 static class SumIf extends SqlAggFunction {
2655 SqlKind.OTHER_FUNCTION,
2658 OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.BOOLEAN),
2659 SqlFunctionCategory.SYSTEM);
2664 return opBinding.getOperandType(0);
2671 SqlKind.OTHER_FUNCTION,
2675 SqlFunctionCategory.SYSTEM);
2677 arg_names = sig.getArgNames();
2687 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
2689 SqlTypeName valueType =
2691 RelDataType subType = typeFactory.createSqlType(valueType, -1);
2692 RelDataType arr = typeFactory.createArrayType(subType, -1);
2696 SqlTypeName ret = sig.getSqlRet();
2697 return typeFactory.createTypeWithNullability(
2698 typeFactory.createSqlType(ret),
true);
2709 SqlKind.OTHER_FUNCTION,
2713 SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
2714 arg_types = sig.getArgs();
2715 outs = sig.getOuts();
2716 out_names = sig.getOutNames();
2717 arg_names = sig.getArgNames();
2721 pretty_arg_names = sig.getPrettyArgNames();
2722 options = sig.getOptions();
2723 cursor_field_types = sig.getCursorFieldTypes();
2733 return pretty_arg_names;
2747 final Boolean has_names = this.pretty_arg_names != null
2748 && this.pretty_arg_names.size() == this.arg_types.size();
2749 final List<FunctionParameter> parameters =
new java.util.ArrayList<>();
2750 for (
int i = 0; i < this.arg_types.size(); i++) {
2751 final int arg_idx = i;
2752 parameters.add(
new FunctionParameter() {
2753 public int getOrdinal() {
2757 public String getName() {
2759 return pretty_arg_names.get(arg_idx);
2761 return "arg" + arg_idx;
2764 public RelDataType getType(RelDataTypeFactory typeFactory) {
2765 SqlTypeFamily
type = toSqlTypeName(arg_types.get(arg_idx)).getFamily();
2766 return type.getDefaultConcreteType(typeFactory);
2769 public boolean isOptional() {
2779 return opBinding -> {
2780 RelDataTypeFactory fact = opBinding.getTypeFactory();
2781 FieldInfoBuilder ret = fact.builder();
2782 for (
int out_idx = 0; out_idx < outs.size(); ++out_idx) {
2784 if (toSqlTypeName(outs.get(out_idx)) == SqlTypeName.ARRAY) {
2787 extSubType = getValueType(extSubType);
2789 RelDataType subtype = fact.createSqlType(toSqlTypeName(extSubType));
2790 type = fact.createArrayType(subtype, -1);
2792 type = fact.createSqlType(toSqlTypeName(outs.get(out_idx)));
2794 ret = ret.add(out_names.get(out_idx), type);
2795 ret = ret.nullable(
true);
2803 System.out.println(msg);
2808 final Boolean debugMode =
false;
2809 Set<RelColumnMapping> s =
new HashSet<RelColumnMapping>();
2810 debugPrint(
"getNameAsId() -> " + getNameAsId() +
", arg_names=" + arg_names
2811 +
", out_names=" + out_names,
2813 if (
Integer.valueOf(options.getOrDefault(
"filter_table_function_transpose",
"0"))
2815 debugPrint(
"getNameAsId() -> " + getNameAsId(), debugMode);
2817 for (
int arg_idx = 0; arg_idx < arg_names.size(); ++arg_idx) {
2818 String arg_name = arg_names.get(arg_idx);
2820 int start = arg_name.indexOf(
"[");
2823 int end = arg_name.lastIndexOf(
"]");
2824 fields = arg_name.substring(start + 1, end)
2825 .replaceAll(
"\\s+",
"")
2828 fields =
new String[] {arg_name};
2830 debugPrint(
"fields=" + Arrays.toString(fields), debugMode);
2831 for (
int field_idx = 0; field_idx < fields.length; ++field_idx) {
2832 int out_idx = out_names.indexOf(fields[field_idx]);
2834 s.add(
new RelColumnMapping(out_idx, rel_idx, field_idx,
false));
2835 debugPrint(
"out_idx, arg_idx/rel_idx, field_idx=" + out_idx +
", " + arg_idx
2836 +
"/" + rel_idx +
", " + field_idx,
2855 StringBuilder ret =
new StringBuilder();
2857 ret.append(this.getName());
2860 for (
int i = 0; i < this.arg_types.size(); i++) {
2866 String paramName = arg_names.get(i);
2867 ret.append(paramName).
append(
" => ");
2869 final String t = type.toString().toUpperCase(Locale.ROOT);
2870 ret.append(
"<").
append(t);
2872 List<ExtensionFunction.ExtArgumentType> field_types =
2873 cursor_field_types.get(paramName);
2875 for (
int j = 0; j < field_types.size(); j++) {
2880 ret.append(toSqlTypeName(field_type));
2881 if (isColumnListType(field_type)) {
2884 ret.append(toSqlTypeName(subtype));
2886 }
else if (isColumnArrayType(field_type) || isArrayType(field_type)) {
2889 ret.append(toSqlTypeName(subtype));
2899 return ret.toString();
2905 return this.arg_names;
2911 return this.getExtendedSignature().hashCode();
2923 if (getClass() != obj.getClass()) {
2932 if (!this.getName().equals(other.getName())) {
2935 if (arg_types.size() != other.arg_types.size()) {
2939 for (
int i = 0; i < arg_types.size(); i++) {
2940 if (arg_types.get(i) != other.arg_types.get(i)) {
2944 String paramName = this.arg_names.get(i);
2945 String otherParamName = other.getExtendedParamNames().
get(i);
2946 if (!paramName.equals(otherParamName)) {
2950 List<ExtArgumentType> field_types = this.getCursorFieldTypes().
get(paramName);
2951 List<ExtArgumentType> other_field_types =
2952 other.getCursorFieldTypes().
get(paramName);
2953 if (field_types.size() != other_field_types.size()) {
2956 for (
int j = 0; j < field_types.size(); j++) {
2957 if (field_types.get(j) != other_field_types.get(j)) {
2968 return new String(getName() +
"("
2970 this.arg_types.stream()
2971 .map(s -> s.toString())
2972 .collect(Collectors.toList()))
2977 return cursor_field_types;
2985 private final List<ExtArgumentType>
outs;
2999 super(
"HeavyDB_Geo_PolyBoundsPtr",
3000 SqlKind.OTHER_FUNCTION,
3003 OperandTypes.family(SqlTypeFamily.ANY),
3004 SqlFunctionCategory.SYSTEM);
3009 assert opBinding.getOperandCount() == 1;
3010 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3011 return typeFactory.createSqlType(SqlTypeName.BIGINT);
3017 super(
"HeavyDB_Geo_PolyRenderGroup",
3018 SqlKind.OTHER_FUNCTION,
3021 OperandTypes.family(SqlTypeFamily.ANY),
3022 SqlFunctionCategory.SYSTEM);
3027 assert opBinding.getOperandCount() == 1;
3028 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3029 return typeFactory.createSqlType(SqlTypeName.INTEGER);
3035 super(
"HeavyDB_Geo_PolyCoordsArray",
3036 SqlKind.OTHER_FUNCTION,
3039 OperandTypes.family(SqlTypeFamily.ANY),
3040 SqlFunctionCategory.SYSTEM);
3045 assert opBinding.getOperandCount() == 1;
3046 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3047 return typeFactory.createArrayType(
3048 typeFactory.createSqlType(SqlTypeName.DOUBLE), -1);
3054 super(
"HeavyDB_Geo_PolyRingSizesArray",
3055 SqlKind.OTHER_FUNCTION,
3058 OperandTypes.family(SqlTypeFamily.ANY),
3059 SqlFunctionCategory.SYSTEM);
3064 assert opBinding.getOperandCount() == 1;
3065 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3066 return typeFactory.createArrayType(
3067 typeFactory.createSqlType(SqlTypeName.INTEGER), -1);
3073 super(
"HeavyDB_Geo_PolyPolyRingsArray",
3074 SqlKind.OTHER_FUNCTION,
3077 OperandTypes.family(SqlTypeFamily.ANY),
3078 SqlFunctionCategory.SYSTEM);
3083 assert opBinding.getOperandCount() == 1;
3084 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3085 return typeFactory.createArrayType(
3086 typeFactory.createSqlType(SqlTypeName.INTEGER), -1);
3092 super(
"convert_meters_to_pixel_width",
3093 SqlKind.OTHER_FUNCTION,
3096 OperandTypes.family(SqlTypeFamily.NUMERIC,
3098 SqlTypeFamily.NUMERIC,
3099 SqlTypeFamily.NUMERIC,
3100 SqlTypeFamily.NUMERIC,
3101 SqlTypeFamily.NUMERIC),
3102 SqlFunctionCategory.SYSTEM);
3107 assert opBinding.getOperandCount() == 6;
3108 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3109 return typeFactory.createSqlType(SqlTypeName.DOUBLE);
3115 super(
"convert_meters_to_pixel_height",
3116 SqlKind.OTHER_FUNCTION,
3119 OperandTypes.family(SqlTypeFamily.NUMERIC,
3121 SqlTypeFamily.NUMERIC,
3122 SqlTypeFamily.NUMERIC,
3123 SqlTypeFamily.NUMERIC,
3124 SqlTypeFamily.NUMERIC),
3125 SqlFunctionCategory.SYSTEM);
3130 assert opBinding.getOperandCount() == 6;
3131 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3132 return typeFactory.createSqlType(SqlTypeName.DOUBLE);
3138 super(
"is_point_in_view",
3139 SqlKind.OTHER_FUNCTION,
3142 OperandTypes.family(SqlTypeFamily.ANY,
3143 SqlTypeFamily.NUMERIC,
3144 SqlTypeFamily.NUMERIC,
3145 SqlTypeFamily.NUMERIC,
3146 SqlTypeFamily.NUMERIC),
3147 SqlFunctionCategory.SYSTEM);
3152 assert opBinding.getOperandCount() == 5;
3153 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3154 return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
3160 super(
"is_point_size_in_view",
3161 SqlKind.OTHER_FUNCTION,
3164 OperandTypes.family(SqlTypeFamily.ANY,
3165 SqlTypeFamily.NUMERIC,
3166 SqlTypeFamily.NUMERIC,
3167 SqlTypeFamily.NUMERIC,
3168 SqlTypeFamily.NUMERIC,
3169 SqlTypeFamily.NUMERIC),
3170 SqlFunctionCategory.SYSTEM);
3175 assert opBinding.getOperandCount() == 6;
3176 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3177 return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
3183 super(
"usTIMESTAMP",
3184 SqlKind.OTHER_FUNCTION,
3187 OperandTypes.STRING,
3188 SqlFunctionCategory.SYSTEM);
3193 assert opBinding.getOperandCount() == 1;
3194 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3195 return typeFactory.createSqlType(SqlTypeName.TIMESTAMP, 6);
3201 super(
"nsTIMESTAMP",
3202 SqlKind.OTHER_FUNCTION,
3205 OperandTypes.STRING,
3206 SqlFunctionCategory.SYSTEM);
3211 assert opBinding.getOperandCount() == 1;
3212 final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
3213 return typeFactory.createSqlType(SqlTypeName.TIMESTAMP, 9);
static java.util.List< SqlTypeFamily > signature()
EXTENSION_NOINLINE double convert_meters_to_pixel_width(const double meters, int8_t *p, const int64_t psize, const int32_t ic, const int32_t isr, const int32_t osr, const double min_lon, const double max_lon, const int32_t img_width, const double min_width)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_INLINE int64_t HeavyDB_Geo_PolyBoundsPtr(double *bounds, int64_t size)
final java.util.List< SqlTypeFamily > toSqlSignature()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static final SqlFunction TRY_CAST
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
size_t append(FILE *f, const size_t size, const int8_t *buf)
Appends the specified number of bytes to the end of the file f from buf.
HeavyDB_Geo_PolyPolyRingsArray()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
ExtTableFunction(final String name, final ExtensionFunction sig)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
List< FunctionParameter > getParameters()
SqlReturnTypeInference getRowTypeInference()
boolean requiresCreate(List< SqlNode > operands)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_NOINLINE double ST_XMax(int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
String getSignatureTemplate(final int operandsCount)
static java.util.List< SqlTypeFamily > getSignatureFamilies()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_NOINLINE bool is_point_size_in_view(int8_t *p, const int64_t psize, const int32_t ic, const double meters, const double min_lon, const double max_lon, const double min_lat, const double max_lat)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
static java.util.List< SqlTypeFamily > signature()
EXTENSION_NOINLINE double ST_YMax(int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
LeftRightTrim(final String name, final SqlKind kind)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_INLINE Array< int32_t > HeavyDB_Geo_PolyRingSizesArray(int32_t *mpoly_ring_sizes, int64_t mpoly_num_rings)
List< ExtArgumentType > getArgTypes()
static java.util.List< SqlTypeFamily > signature()
SqlCall createCall(@Nullable SqlLiteral functionQualifier, SqlParserPos pos,@Nullable SqlNode...operands)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_NOINLINE double ST_XMin(int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
static java.util.List< SqlTypeFamily > signature()
static String dropSuffix(final String str)
static java.util.List< SqlTypeFamily > signature()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RegexpSubstr(final String alias)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
String getExtendedSignature()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
final Map< String, String > options
List< String > getParamNames()
static java.util.List< SqlTypeFamily > signature()
EXTENSION_NOINLINE double convert_meters_to_pixel_height(const double meters, int8_t *p, const int64_t psize, const int32_t ic, const int32_t isr, const int32_t osr, const double min_lat, const double max_lat, const int32_t img_height, const double min_height)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
boolean equals(final Object obj)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
convert_meters_to_pixel_height()
boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
final List< ExtArgumentType > outs
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static final Logger HEAVYDBLOGGER
RelDataType inferReturnType(SqlOperatorBinding opBinding)
final ListSqlOperatorTable listOpTab
static java.util.List< SqlTypeFamily > getSignatureFamilies()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > getSignatureFamilies()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType getComponentType(RelDataTypeFactory typeFactory, List< RelDataType > argTypes)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > getSignatureFamilies()
void debugPrint(String msg, Boolean debugMode)
final List< ExtArgumentType > arg_types
EXTENSION_NOINLINE double ST_YMin(int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
static java.util.List< SqlTypeFamily > signature()
final ExtensionFunction sig
EXTENSION_INLINE Array< double > HeavyDB_Geo_PolyCoordsArray(int8_t *mpoly_coords, int64_t mpoly_coords_size, const int32_t ic)
boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
SqlCall createCall(@Nullable SqlLiteral functionQualifier, SqlParserPos pos,@Nullable SqlNode...operands)
static java.util.List< SqlTypeFamily > getSignatureFamilies()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
HeavyDB_Geo_PolyRenderGroup()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
static boolean isColumnArrayType(final ExtArgumentType type)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_INLINE int32_t HeavyDB_Geo_PolyRenderGroup(int32_t render_group)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
void addUDF(final Map< String, ExtensionFunction > extSigs)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
HeavyDBSqlOperatorTable(SqlOperatorTable parentTable)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > getSignatureFamilies()
EXTENSION_NOINLINE bool is_point_in_view(int8_t *p, const int64_t psize, const int32_t ic, const double min_lon, const double max_lon, const double min_lat, const double max_lat)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
ExtFunction(final String name, final ExtensionFunction sig)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
static java.util.List< SqlTypeFamily > getSignatureFamilies()
convert_meters_to_pixel_width()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
SqlOperandCountRange getOperandCountRange()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
final List< String > out_names
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
void addOperator(SqlOperator op)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
HeavyDB_Geo_PolyBoundsPtr()
static java.util.List< SqlTypeFamily > getSignatureFamilies()
static java.util.List< SqlTypeFamily > signature()
final Map< String, List< ExtArgumentType > > cursor_field_types
RelDataType inferReturnType(SqlOperatorBinding opBinding)
final List< String > arg_names
static java.util.List< SqlTypeFamily > signature()
static java.util.List< SqlTypeFamily > signature()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
static java.util.List< SqlTypeFamily > signature()
void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
final List< String > arg_names
RelDataType inferReturnType(SqlOperatorBinding opBinding)
List< String > getParamNames()
static boolean isArrayType(final ExtArgumentType type)
boolean requiresCreate(List< SqlNode > operands)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
Set< RelColumnMapping > getColumnMappings()
HeavyDB_Geo_PolyRingSizesArray()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
SqlCall createCall(@Nullable SqlLiteral functionQualifier, SqlParserPos pos,@Nullable SqlNode...operands)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > getSignatureFamilies()
SqlCall createCall(@Nullable SqlLiteral functionQualifier, SqlParserPos pos,@Nullable SqlNode...operands)
EXTENSION_NOINLINE double Truncate(const double x, const int32_t y)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_INLINE Array< int32_t > HeavyDB_Geo_PolyPolyRingsArray(int32_t *mpoly_poly_sizes, int64_t mpoly_num_polys)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
final List< String > pretty_arg_names
static java.util.List< SqlTypeFamily > signature()
Map< String, List< ExtArgumentType > > getCursorFieldTypes()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
SqlCall createCall(@Nullable SqlLiteral functionQualifier, SqlParserPos pos,@Nullable SqlNode...operands)
boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static final SqlArrayValueConstructorAllowingEmpty ARRAY_VALUE_CONSTRUCTOR
RelDataType inferReturnType(SqlOperatorBinding opBinding)
boolean requiresCreate(List< SqlNode > operands)
static ExtArgumentType getValueType(final ExtArgumentType type)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
List< String > getExtendedParamNames()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
HeavyDB_Geo_PolyCoordsArray()
static java.util.List< SqlTypeFamily > getSignatureFamilies()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
void lookupOperatorOverloads(SqlIdentifier opName, SqlFunctionCategory category, SqlSyntax syntax, List< SqlOperator > operatorList, SqlNameMatcher nameMatcher)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
LeftRightPad(final String name)