OmniSciDB  ab4938a6a3
MapDSqlOperatorTable.java
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.mapd.calcite.parser;
17 
18 import com.google.common.base.Predicate;
19 import com.google.common.collect.ImmutableList;
20 import com.google.common.collect.Multimap;
22 
23 import org.apache.calcite.rel.type.RelDataType;
24 import org.apache.calcite.rel.type.RelDataTypeFactory;
25 import org.apache.calcite.sql.SqlAggFunction;
26 import org.apache.calcite.sql.SqlCallBinding;
27 import org.apache.calcite.sql.SqlFunction;
28 import org.apache.calcite.sql.SqlFunctionCategory;
29 import org.apache.calcite.sql.SqlIdentifier;
30 import org.apache.calcite.sql.SqlKind;
31 import org.apache.calcite.sql.SqlOperator;
32 import org.apache.calcite.sql.SqlOperatorBinding;
33 import org.apache.calcite.sql.SqlOperatorTable;
34 import org.apache.calcite.sql.SqlSyntax;
35 import org.apache.calcite.sql.fun.SqlArrayValueConstructor;
36 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
37 import org.apache.calcite.sql.type.OperandTypes;
38 import org.apache.calcite.sql.type.SqlTypeFamily;
39 import org.apache.calcite.sql.type.SqlTypeName;
40 import org.apache.calcite.sql.util.ChainedSqlOperatorTable;
41 import org.apache.calcite.sql.util.ListSqlOperatorTable;
42 import org.apache.calcite.sql.util.ReflectiveSqlOperatorTable;
43 import org.apache.calcite.sql.validate.SqlNameMatcher;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
46 
47 import java.lang.reflect.Field;
48 import java.util.HashSet;
49 import java.util.Iterator;
50 import java.util.List;
51 import java.util.Map;
52 
53 class CaseInsensitiveListSqlOperatorTable extends ListSqlOperatorTable {
54  @Override
55  public void lookupOperatorOverloads(SqlIdentifier opName,
56  SqlFunctionCategory category,
57  SqlSyntax syntax,
58  List<SqlOperator> operatorList,
59  SqlNameMatcher nameMatcher) {
60  for (SqlOperator operator : this.getOperatorList()) {
61  if (operator.getSyntax() != syntax) {
62  continue;
63  }
64  if (!opName.isSimple()
65  || !nameMatcher.matches(operator.getName(), opName.getSimple())) {
66  continue;
67  }
68  SqlFunctionCategory functionCategory;
69  if (operator instanceof SqlFunction) {
70  functionCategory = ((SqlFunction) operator).getFunctionType();
71  } else {
72  functionCategory = SqlFunctionCategory.SYSTEM;
73  }
74  if (category != functionCategory
75  && category != SqlFunctionCategory.USER_DEFINED_FUNCTION) {
76  continue;
77  }
78  operatorList.add(operator);
79  }
80  }
81 }
82 
87 public class MapDSqlOperatorTable extends ChainedSqlOperatorTable {
88  public static final SqlArrayValueConstructorAllowingEmpty ARRAY_VALUE_CONSTRUCTOR =
90 
91  static {
92  try {
93  // some nasty bit to remove the std APPROX_COUNT_DISTINCT function definition
94  {
95  Field f = ReflectiveSqlOperatorTable.class.getDeclaredField(
96  "caseSensitiveOperators");
97  f.setAccessible(true);
98  Multimap operators = (Multimap) f.get(SqlStdOperatorTable.instance());
99  for (Iterator i = operators.entries().iterator(); i.hasNext();) {
100  Map.Entry entry = (Map.Entry) i.next();
101  if (entry.getValue() == SqlStdOperatorTable.APPROX_COUNT_DISTINCT
102  || entry.getValue() == SqlStdOperatorTable.AVG
103  || entry.getValue() == SqlStdOperatorTable.ARRAY_VALUE_CONSTRUCTOR) {
104  i.remove();
105  }
106  }
107  }
108 
109  {
110  Field f = ReflectiveSqlOperatorTable.class.getDeclaredField(
111  "caseInsensitiveOperators");
112  f.setAccessible(true);
113  Multimap operators = (Multimap) f.get(SqlStdOperatorTable.instance());
114  for (Iterator i = operators.entries().iterator(); i.hasNext();) {
115  Map.Entry entry = (Map.Entry) i.next();
116  if (entry.getValue() == SqlStdOperatorTable.APPROX_COUNT_DISTINCT
117  || entry.getValue() == SqlStdOperatorTable.AVG
118  || entry.getValue() == SqlStdOperatorTable.ARRAY_VALUE_CONSTRUCTOR) {
119  i.remove();
120  }
121  }
122  }
123 
124  SqlStdOperatorTable.instance().register(ARRAY_VALUE_CONSTRUCTOR);
125 
126  } catch (Exception e) {
127  throw new RuntimeException(e);
128  }
129 
130  // register our approx count distinct against std table
131  // SqlStdOperatorTable.instance().register(new ApproxCountDistinct());
132  }
133 
134  final static Logger MAPDLOGGER = LoggerFactory.getLogger(MapDSqlOperatorTable.class);
135 
140  // ~ Instance fields --------------------------------------------------------
141  private final ListSqlOperatorTable listOpTab;
142 
143  // ~ Constructors -----------------------------------------------------------
144  public MapDSqlOperatorTable(SqlOperatorTable parentTable) {
145  super(ImmutableList.of(parentTable, new CaseInsensitiveListSqlOperatorTable()));
146  listOpTab = (ListSqlOperatorTable) tableList.get(1);
147  }
148 
149  // ~ Methods ----------------------------------------------------------------
155  public void addOperator(SqlOperator op) {
156  listOpTab.add(op);
157  }
158 
159  public static void addUDF(
160  MapDSqlOperatorTable opTab, final Map<String, ExtensionFunction> extSigs) {
161  // Don't use anonymous inner classes. They can't be instantiated
162  // using reflection when we are deserializing from JSON.
163  // opTab.addOperator(new RampFunction());
164  // opTab.addOperator(new DedupFunction());
165  opTab.addOperator(new RowCopier()); // Table UDF prototype
166  opTab.addOperator(new MyUDFFunction());
167  opTab.addOperator(new PgUnnest());
168  opTab.addOperator(new Any());
169  opTab.addOperator(new All());
170  opTab.addOperator(new Now());
171  opTab.addOperator(new Datetime());
172  opTab.addOperator(new PgExtract());
173  opTab.addOperator(new Dateadd());
174  opTab.addOperator(new Datediff());
175  opTab.addOperator(new Datepart());
176  opTab.addOperator(new PgDateTrunc());
177  opTab.addOperator(new Length());
178  opTab.addOperator(new CharLength());
179  opTab.addOperator(new KeyForString());
180  opTab.addOperator(new ArrayLength());
181  opTab.addOperator(new PgILike());
182  opTab.addOperator(new RegexpLike());
183  opTab.addOperator(new Likely());
184  opTab.addOperator(new Unlikely());
185  opTab.addOperator(new Sign());
186  opTab.addOperator(new Truncate());
187  opTab.addOperator(new ST_Contains());
188  opTab.addOperator(new ST_Intersects());
189  opTab.addOperator(new ST_Overlaps());
190  opTab.addOperator(new ST_Disjoint());
191  opTab.addOperator(new ST_Within());
192  opTab.addOperator(new ST_DWithin());
193  opTab.addOperator(new ST_DFullyWithin());
194  opTab.addOperator(new ST_Distance());
195  opTab.addOperator(new ST_MaxDistance());
196  opTab.addOperator(new ST_GeogFromText());
197  opTab.addOperator(new ST_GeomFromText());
198  opTab.addOperator(new ST_Transform());
199  opTab.addOperator(new ST_X());
200  opTab.addOperator(new ST_Y());
201  opTab.addOperator(new ST_XMin());
202  opTab.addOperator(new ST_XMax());
203  opTab.addOperator(new ST_YMin());
204  opTab.addOperator(new ST_YMax());
205  opTab.addOperator(new ST_PointN());
206  opTab.addOperator(new ST_StartPoint());
207  opTab.addOperator(new ST_EndPoint());
208  opTab.addOperator(new ST_Length());
209  opTab.addOperator(new ST_Perimeter());
210  opTab.addOperator(new ST_Area());
211  opTab.addOperator(new ST_NPoints());
212  opTab.addOperator(new ST_NRings());
213  opTab.addOperator(new ST_SRID());
214  opTab.addOperator(new ST_SetSRID());
215  opTab.addOperator(new ST_Point());
216  opTab.addOperator(new CastToGeography());
217  opTab.addOperator(new OffsetInFragment());
218  opTab.addOperator(new ApproxCountDistinct());
219  opTab.addOperator(new MapDAvg());
220  opTab.addOperator(new Sample());
221  opTab.addOperator(new LastSample());
222  // MapD_Geo* are deprecated in place of the OmniSci_Geo_ varietals
223  opTab.addOperator(new MapD_GeoPolyBoundsPtr());
229  opTab.addOperator(new is_point_in_view());
230  opTab.addOperator(new is_point_size_in_view());
231  opTab.addOperator(new usTimestamp());
232  opTab.addOperator(new nsTimestamp());
233  if (extSigs == null) {
234  return;
235  }
236  HashSet<String> demangledNames = new HashSet<String>();
237  for (Map.Entry<String, ExtensionFunction> extSig : extSigs.entrySet()) {
238  final String demangledName = dropSuffix(extSig.getKey());
239  if (demangledNames.contains(demangledName)) {
240  continue;
241  }
242  demangledNames.add(demangledName);
243  opTab.addOperator(new ExtFunction(demangledName, extSig.getValue()));
244  }
245  }
246 
247  private static String dropSuffix(final String str) {
248  int suffix_idx = str.indexOf("__");
249  if (suffix_idx == -1) {
250  return str;
251  }
252  assert suffix_idx > 0;
253  return str.substring(0, suffix_idx);
254  }
255 
257  extends SqlArrayValueConstructor {
258  @Override
259  protected RelDataType getComponentType(
260  RelDataTypeFactory typeFactory, List<RelDataType> argTypes) {
261  if (argTypes.isEmpty()) {
262  return typeFactory.createSqlType(SqlTypeName.NULL);
263  }
264  return super.getComponentType(typeFactory, argTypes);
265  }
266 
267  @Override
268  public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure) {
269  if (callBinding.operands().isEmpty()) {
270  return true;
271  }
272  return super.checkOperandTypes(callBinding, throwOnFailure);
273  }
274  }
275 
279  public static class RampFunction extends SqlFunction {
280  public RampFunction() {
281  super("RAMP",
282  SqlKind.OTHER_FUNCTION,
283  null,
284  null,
285  OperandTypes.NUMERIC,
286  SqlFunctionCategory.USER_DEFINED_FUNCTION);
287  }
288 
289  @Override
290  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
291  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
292  return typeFactory.builder().add("I", SqlTypeName.INTEGER).build();
293  }
294  }
295 
299  public static class DedupFunction extends SqlFunction {
300  public DedupFunction() {
301  super("DEDUP",
302  SqlKind.OTHER_FUNCTION,
303  null,
304  null,
305  OperandTypes.VARIADIC,
306  SqlFunctionCategory.USER_DEFINED_FUNCTION);
307  }
308 
309  @Override
310  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
311  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
312  return typeFactory.builder().add("NAME", SqlTypeName.VARCHAR, 1024).build();
313  }
314  }
315 
320  public static class MyUDFFunction extends SqlFunction {
321  public MyUDFFunction() {
322  super("MyUDF",
323  SqlKind.OTHER_FUNCTION,
324  null,
325  null,
326  OperandTypes.STRING_STRING,
327  SqlFunctionCategory.SYSTEM);
328  }
329 
330  @Override
331  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
332  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
333  return typeFactory.createSqlType(SqlTypeName.BIGINT);
334  }
335  }
336 
340  public static class RowCopier extends SqlFunction {
341  public RowCopier() {
342  super("ROW_COPIER",
343  SqlKind.OTHER_FUNCTION,
344  null,
345  null,
346  OperandTypes.family(signature()),
347  SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
348  }
349 
350  @Override
351  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
352  assert opBinding.getOperandCount() == 2;
353  return opBinding.getCursorOperand(0);
354  }
355 
356  private static java.util.List<SqlTypeFamily> signature() {
357  java.util.List<SqlTypeFamily> sig_family = new java.util.ArrayList<SqlTypeFamily>();
358  sig_family.add(SqlTypeFamily.CURSOR);
359  sig_family.add(SqlTypeFamily.ANY);
360  return sig_family;
361  }
362  }
363 
364  /* Postgres-style UNNEST */
365  public static class PgUnnest extends SqlFunction {
366  public PgUnnest() {
367  super("PG_UNNEST",
368  SqlKind.OTHER_FUNCTION,
369  null,
370  null,
371  OperandTypes.ARRAY,
372  SqlFunctionCategory.SYSTEM);
373  }
374 
375  @Override
376  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
377  assert opBinding.getOperandCount() == 1;
378  RelDataType elem_type = opBinding.getOperandType(0).getComponentType();
379  assert elem_type != null;
380  return elem_type;
381  }
382  }
383 
384  /* ANY qualifier */
385  public static class Any extends SqlFunction {
386  public Any() {
387  super("PG_ANY",
388  SqlKind.OTHER_FUNCTION,
389  null,
390  null,
391  OperandTypes.ARRAY,
392  SqlFunctionCategory.SYSTEM);
393  }
394 
395  @Override
396  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
397  assert opBinding.getOperandCount() == 1;
398  RelDataType elem_type = opBinding.getOperandType(0).getComponentType();
399  assert elem_type != null;
400  return elem_type;
401  }
402  }
403 
404  /* ALL qualifier */
405  public static class All extends SqlFunction {
406  public All() {
407  super("PG_ALL",
408  SqlKind.OTHER_FUNCTION,
409  null,
410  null,
411  OperandTypes.ARRAY,
412  SqlFunctionCategory.SYSTEM);
413  }
414 
415  @Override
416  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
417  assert opBinding.getOperandCount() == 1;
418  RelDataType elem_type = opBinding.getOperandType(0).getComponentType();
419  assert elem_type != null;
420  return elem_type;
421  }
422  }
423 
424  /* NOW() */
425  public static class Now extends SqlFunction {
426  public Now() {
427  super("NOW",
428  SqlKind.OTHER_FUNCTION,
429  null,
430  null,
431  OperandTypes.NILADIC,
432  SqlFunctionCategory.SYSTEM);
433  }
434 
435  @Override
436  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
437  assert opBinding.getOperandCount() == 0;
438  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
439  return typeFactory.createSqlType(SqlTypeName.TIMESTAMP);
440  }
441  }
442 
443  /* DATETIME */
444  public static class Datetime extends SqlFunction {
445  public Datetime() {
446  super("DATETIME",
447  SqlKind.OTHER_FUNCTION,
448  null,
449  null,
450  OperandTypes.STRING,
451  SqlFunctionCategory.SYSTEM);
452  }
453 
454  @Override
455  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
456  assert opBinding.getOperandCount() == 1;
457  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
458  return typeFactory.createSqlType(
459  SqlTypeName.TIMESTAMP, opBinding.getOperandType(0).getPrecision());
460  }
461  }
462 
463  /* Postgres-style EXTRACT */
464  public static class PgExtract extends SqlFunction {
465  public PgExtract() {
466  super("PG_EXTRACT",
467  SqlKind.OTHER_FUNCTION,
468  null,
469  null,
470  OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.DATETIME),
471  SqlFunctionCategory.SYSTEM);
472  }
473 
474  @Override
475  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
476  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
477  return typeFactory.createTypeWithNullability(
478  typeFactory.createSqlType(SqlTypeName.BIGINT),
479  opBinding.getOperandType(1).isNullable());
480  }
481  }
482 
483  public static class Datepart extends SqlFunction {
484  public Datepart() {
485  super("DATEPART",
486  SqlKind.OTHER_FUNCTION,
487  null,
488  null,
489  OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.DATETIME),
490  SqlFunctionCategory.TIMEDATE);
491  }
492 
493  @Override
494  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
495  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
496  return typeFactory.createTypeWithNullability(
497  typeFactory.createSqlType(SqlTypeName.BIGINT),
498  opBinding.getOperandType(1).isNullable());
499  }
500  }
501 
502  public static class Dateadd extends SqlFunction {
503  public Dateadd() {
504  super("DATEADD",
505  SqlKind.OTHER_FUNCTION,
506  null,
507  null,
508  OperandTypes.family(SqlTypeFamily.STRING,
509  SqlTypeFamily.INTEGER,
510  SqlTypeFamily.DATETIME),
511  SqlFunctionCategory.TIMEDATE);
512  }
513 
514  @Override
515  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
516  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
517  return typeFactory.createTypeWithNullability(
518  typeFactory.createSqlType(
519  SqlTypeName.TIMESTAMP, opBinding.getOperandType(2).getPrecision()),
520  opBinding.getOperandType(2).isNullable());
521  }
522  }
523 
524  public static class Datediff extends SqlFunction {
525  public Datediff() {
526  super("DATEDIFF",
527  SqlKind.OTHER_FUNCTION,
528  null,
529  null,
530  OperandTypes.family(SqlTypeFamily.STRING,
531  SqlTypeFamily.DATETIME,
532  SqlTypeFamily.DATETIME),
533  SqlFunctionCategory.TIMEDATE);
534  }
535 
536  @Override
537  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
538  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
539  return typeFactory.createTypeWithNullability(
540  typeFactory.createSqlType(SqlTypeName.BIGINT),
541  opBinding.getOperandType(1).isNullable()
542  || opBinding.getOperandType(2).isNullable());
543  }
544  }
545 
546  /* Postgres-style DATE_TRUNC */
547  public static class PgDateTrunc extends SqlFunction {
548  public PgDateTrunc() {
549  super("PG_DATE_TRUNC",
550  SqlKind.OTHER_FUNCTION,
551  null,
552  null,
553  OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.DATETIME),
554  SqlFunctionCategory.SYSTEM);
555  }
556 
557  @Override
558  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
559  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
560  return typeFactory.createTypeWithNullability(
561  typeFactory.createSqlType(
562  SqlTypeName.TIMESTAMP, opBinding.getOperandType(1).getPrecision()),
563  opBinding.getOperandType(1).isNullable());
564  }
565  }
566 
567  public static class Length extends SqlFunction {
568  public Length() {
569  super("LENGTH",
570  SqlKind.OTHER_FUNCTION,
571  null,
572  null,
573  OperandTypes.STRING,
574  SqlFunctionCategory.SYSTEM);
575  }
576 
577  @Override
578  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
579  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
580  return typeFactory.createSqlType(SqlTypeName.INTEGER);
581  }
582  }
583 
584  public static class CharLength extends SqlFunction {
585  public CharLength() {
586  super("CHAR_LENGTH",
587  SqlKind.OTHER_FUNCTION,
588  null,
589  null,
590  OperandTypes.STRING,
591  SqlFunctionCategory.SYSTEM);
592  }
593 
594  @Override
595  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
596  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
597  return typeFactory.createSqlType(SqlTypeName.INTEGER);
598  }
599  }
600 
601  public static class KeyForString extends SqlFunction {
602  public KeyForString() {
603  super("KEY_FOR_STRING",
604  SqlKind.OTHER_FUNCTION,
605  null,
606  null,
607  OperandTypes.STRING,
608  SqlFunctionCategory.SYSTEM);
609  }
610 
611  @Override
612  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
613  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
614  return typeFactory.createTypeWithNullability(
615  typeFactory.createSqlType(SqlTypeName.INTEGER),
616  opBinding.getOperandType(0).isNullable());
617  }
618  }
619 
620  public static class ArrayLength extends SqlFunction {
621  public ArrayLength() {
622  super("ARRAY_LENGTH",
623  SqlKind.OTHER_FUNCTION,
624  null,
625  null,
626  OperandTypes.ARRAY,
627  SqlFunctionCategory.SYSTEM);
628  }
629 
630  @Override
631  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
632  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
633  return typeFactory.createSqlType(SqlTypeName.INTEGER);
634  }
635  }
636 
637  public static class PgILike extends SqlFunction {
638  public PgILike() {
639  super("PG_ILIKE",
640  SqlKind.OTHER_FUNCTION,
641  null,
642  null,
643  OperandTypes.family(getSignatureFamilies(), new EscapeOptional()),
644  SqlFunctionCategory.SYSTEM);
645  }
646 
647  private static java.util.List<SqlTypeFamily> getSignatureFamilies() {
648  java.util.ArrayList<SqlTypeFamily> families =
649  new java.util.ArrayList<SqlTypeFamily>();
650  families.add(SqlTypeFamily.STRING);
651  families.add(SqlTypeFamily.STRING);
652  families.add(SqlTypeFamily.STRING);
653  return families;
654  }
655 
656  private static class EscapeOptional
657  implements java.util.function.Predicate<Integer>, Predicate<Integer> {
658  @Override
659  public boolean test(Integer t) {
660  return apply(t);
661  }
662 
663  @Override
664  public boolean apply(Integer t) {
665  return t == 2;
666  }
667  }
668 
669  @Override
670  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
671  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
672  return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
673  }
674  }
675 
676  public static class RegexpLike extends SqlFunction {
677  public RegexpLike() {
678  super("REGEXP_LIKE",
679  SqlKind.OTHER_FUNCTION,
680  null,
681  null,
682  OperandTypes.family(getSignatureFamilies(), new EscapeOptional()),
683  SqlFunctionCategory.SYSTEM);
684  }
685 
686  private static java.util.List<SqlTypeFamily> getSignatureFamilies() {
687  java.util.ArrayList<SqlTypeFamily> families =
688  new java.util.ArrayList<SqlTypeFamily>();
689  families.add(SqlTypeFamily.STRING);
690  families.add(SqlTypeFamily.STRING);
691  families.add(SqlTypeFamily.STRING);
692  return families;
693  }
694 
695  private static class EscapeOptional
696  implements java.util.function.Predicate<Integer>, Predicate<Integer> {
697  @Override
698  public boolean test(Integer t) {
699  return apply(t);
700  }
701 
702  public boolean apply(Integer t) {
703  return t == 2;
704  }
705  }
706 
707  @Override
708  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
709  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
710  return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
711  }
712  }
713 
714  public static class Likely extends SqlFunction {
715  public Likely() {
716  super("LIKELY",
717  SqlKind.OTHER_FUNCTION,
718  null,
719  null,
720  OperandTypes.BOOLEAN,
721  SqlFunctionCategory.SYSTEM);
722  }
723 
724  @Override
725  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
726  return opBinding.getOperandType(0);
727  }
728  }
729 
730  public static class Unlikely extends SqlFunction {
731  public Unlikely() {
732  super("UNLIKELY",
733  SqlKind.OTHER_FUNCTION,
734  null,
735  null,
736  OperandTypes.BOOLEAN,
737  SqlFunctionCategory.SYSTEM);
738  }
739 
740  @Override
741  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
742  return opBinding.getOperandType(0);
743  }
744  }
745 
746  public static class Sign extends SqlFunction {
747  public Sign() {
748  super("SIGN",
749  SqlKind.OTHER_FUNCTION,
750  null,
751  null,
752  OperandTypes.NUMERIC,
753  SqlFunctionCategory.NUMERIC);
754  }
755 
756  @Override
757  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
758  return opBinding.getOperandType(0);
759  }
760  }
761 
762  static class Truncate extends SqlFunction {
764  super("TRUNCATE",
765  SqlKind.OTHER_FUNCTION,
766  null,
767  null,
768  OperandTypes.family(signature()),
769  SqlFunctionCategory.NUMERIC);
770  }
771 
772  @Override
773  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
774  assert opBinding.getOperandCount() == 2;
775  return opBinding.getOperandType(0);
776  }
777 
778  private static java.util.List<SqlTypeFamily> signature() {
779  java.util.List<SqlTypeFamily> truncate_sig =
780  new java.util.ArrayList<SqlTypeFamily>();
781  truncate_sig.add(SqlTypeFamily.NUMERIC);
782  truncate_sig.add(SqlTypeFamily.INTEGER);
783  return truncate_sig;
784  }
785  }
786 
787  static class ST_Contains extends SqlFunction {
789  super("ST_Contains",
790  SqlKind.OTHER_FUNCTION,
791  null,
792  null,
793  OperandTypes.family(signature()),
794  SqlFunctionCategory.SYSTEM);
795  }
796 
797  @Override
798  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
799  assert opBinding.getOperandCount() == 2;
800  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
801  return typeFactory.createTypeWithNullability(
802  typeFactory.createSqlType(SqlTypeName.BOOLEAN),
803  opBinding.getOperandType(0).isNullable()
804  || opBinding.getOperandType(1).isNullable());
805  }
806 
807  private static java.util.List<SqlTypeFamily> signature() {
808  java.util.List<SqlTypeFamily> st_contains_sig =
809  new java.util.ArrayList<SqlTypeFamily>();
810  st_contains_sig.add(SqlTypeFamily.ANY);
811  st_contains_sig.add(SqlTypeFamily.ANY);
812  return st_contains_sig;
813  }
814  }
815 
816  static class ST_Intersects extends SqlFunction {
818  super("ST_Intersects",
819  SqlKind.OTHER_FUNCTION,
820  null,
821  null,
822  OperandTypes.family(signature()),
823  SqlFunctionCategory.SYSTEM);
824  }
825 
826  @Override
827  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
828  assert opBinding.getOperandCount() == 2;
829  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
830  return typeFactory.createTypeWithNullability(
831  typeFactory.createSqlType(SqlTypeName.BOOLEAN),
832  opBinding.getOperandType(0).isNullable()
833  || opBinding.getOperandType(1).isNullable());
834  }
835 
836  private static java.util.List<SqlTypeFamily> signature() {
837  java.util.List<SqlTypeFamily> st_intersects_sig =
838  new java.util.ArrayList<SqlTypeFamily>();
839  st_intersects_sig.add(SqlTypeFamily.ANY);
840  st_intersects_sig.add(SqlTypeFamily.ANY);
841  return st_intersects_sig;
842  }
843  }
844 
845  static class ST_Overlaps extends SqlFunction {
847  super("ST_Overlaps",
848  SqlKind.OTHER_FUNCTION,
849  null,
850  null,
851  OperandTypes.family(signature()),
852  SqlFunctionCategory.SYSTEM);
853  }
854 
855  @Override
856  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
857  assert opBinding.getOperandCount() == 2;
858  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
859  return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
860  }
861 
862  private static java.util.List<SqlTypeFamily> signature() {
863  java.util.List<SqlTypeFamily> st_overlaps_sig =
864  new java.util.ArrayList<SqlTypeFamily>();
865  st_overlaps_sig.add(SqlTypeFamily.ANY);
866  st_overlaps_sig.add(SqlTypeFamily.ANY);
867  return st_overlaps_sig;
868  }
869  }
870 
871  static class ST_Disjoint extends SqlFunction {
873  super("ST_Disjoint",
874  SqlKind.OTHER_FUNCTION,
875  null,
876  null,
877  OperandTypes.family(signature()),
878  SqlFunctionCategory.SYSTEM);
879  }
880 
881  @Override
882  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
883  assert opBinding.getOperandCount() == 2;
884  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
885  return typeFactory.createTypeWithNullability(
886  typeFactory.createSqlType(SqlTypeName.BOOLEAN),
887  opBinding.getOperandType(0).isNullable()
888  || opBinding.getOperandType(1).isNullable());
889  }
890 
891  private static java.util.List<SqlTypeFamily> signature() {
892  java.util.List<SqlTypeFamily> st_disjoint_sig =
893  new java.util.ArrayList<SqlTypeFamily>();
894  st_disjoint_sig.add(SqlTypeFamily.ANY);
895  st_disjoint_sig.add(SqlTypeFamily.ANY);
896  return st_disjoint_sig;
897  }
898  }
899 
900  static class ST_Within extends SqlFunction {
902  super("ST_Within",
903  SqlKind.OTHER_FUNCTION,
904  null,
905  null,
906  OperandTypes.family(signature()),
907  SqlFunctionCategory.SYSTEM);
908  }
909 
910  @Override
911  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
912  assert opBinding.getOperandCount() == 2;
913  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
914  return typeFactory.createTypeWithNullability(
915  typeFactory.createSqlType(SqlTypeName.BOOLEAN),
916  opBinding.getOperandType(0).isNullable()
917  || opBinding.getOperandType(1).isNullable());
918  }
919 
920  private static java.util.List<SqlTypeFamily> signature() {
921  java.util.List<SqlTypeFamily> st_within_sig =
922  new java.util.ArrayList<SqlTypeFamily>();
923  st_within_sig.add(SqlTypeFamily.ANY);
924  st_within_sig.add(SqlTypeFamily.ANY);
925  return st_within_sig;
926  }
927  }
928 
929  static class ST_DWithin extends SqlFunction {
931  super("ST_DWithin",
932  SqlKind.OTHER_FUNCTION,
933  null,
934  null,
935  OperandTypes.family(signature()),
936  SqlFunctionCategory.SYSTEM);
937  }
938 
939  @Override
940  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
941  assert opBinding.getOperandCount() == 3;
942  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
943  return typeFactory.createTypeWithNullability(
944  typeFactory.createSqlType(SqlTypeName.BOOLEAN),
945  opBinding.getOperandType(0).isNullable()
946  || opBinding.getOperandType(1).isNullable()
947  || opBinding.getOperandType(2).isNullable());
948  }
949 
950  private static java.util.List<SqlTypeFamily> signature() {
951  java.util.List<SqlTypeFamily> st_dwithin_sig =
952  new java.util.ArrayList<SqlTypeFamily>();
953  st_dwithin_sig.add(SqlTypeFamily.ANY);
954  st_dwithin_sig.add(SqlTypeFamily.ANY);
955  st_dwithin_sig.add(SqlTypeFamily.NUMERIC);
956  return st_dwithin_sig;
957  }
958  }
959 
960  static class ST_DFullyWithin extends SqlFunction {
962  super("ST_DFullyWithin",
963  SqlKind.OTHER_FUNCTION,
964  null,
965  null,
966  OperandTypes.family(signature()),
967  SqlFunctionCategory.SYSTEM);
968  }
969 
970  @Override
971  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
972  assert opBinding.getOperandCount() == 3;
973  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
974  return typeFactory.createTypeWithNullability(
975  typeFactory.createSqlType(SqlTypeName.BOOLEAN),
976  opBinding.getOperandType(0).isNullable()
977  || opBinding.getOperandType(1).isNullable()
978  || opBinding.getOperandType(2).isNullable());
979  }
980 
981  private static java.util.List<SqlTypeFamily> signature() {
982  java.util.List<SqlTypeFamily> st_dwithin_sig =
983  new java.util.ArrayList<SqlTypeFamily>();
984  st_dwithin_sig.add(SqlTypeFamily.ANY);
985  st_dwithin_sig.add(SqlTypeFamily.ANY);
986  st_dwithin_sig.add(SqlTypeFamily.NUMERIC);
987  return st_dwithin_sig;
988  }
989  }
990 
991  static class ST_Distance extends SqlFunction {
993  super("ST_Distance",
994  SqlKind.OTHER_FUNCTION,
995  null,
996  null,
997  OperandTypes.family(signature()),
998  SqlFunctionCategory.SYSTEM);
999  }
1000 
1001  @Override
1002  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1003  assert opBinding.getOperandCount() == 2;
1004  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1005  return typeFactory.createTypeWithNullability(
1006  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1007  opBinding.getOperandType(0).isNullable()
1008  || opBinding.getOperandType(1).isNullable());
1009  }
1010 
1011  private static java.util.List<SqlTypeFamily> signature() {
1012  java.util.List<SqlTypeFamily> st_distance_sig =
1013  new java.util.ArrayList<SqlTypeFamily>();
1014  st_distance_sig.add(SqlTypeFamily.ANY);
1015  st_distance_sig.add(SqlTypeFamily.ANY);
1016  return st_distance_sig;
1017  }
1018  }
1019 
1020  static class ST_MaxDistance extends SqlFunction {
1022  super("ST_MaxDistance",
1023  SqlKind.OTHER_FUNCTION,
1024  null,
1025  null,
1026  OperandTypes.family(signature()),
1027  SqlFunctionCategory.SYSTEM);
1028  }
1029 
1030  @Override
1031  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1032  assert opBinding.getOperandCount() == 2;
1033  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1034  return typeFactory.createTypeWithNullability(
1035  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1036  opBinding.getOperandType(0).isNullable()
1037  || opBinding.getOperandType(1).isNullable());
1038  }
1039 
1040  private static java.util.List<SqlTypeFamily> signature() {
1041  java.util.List<SqlTypeFamily> st_maxdistance_sig =
1042  new java.util.ArrayList<SqlTypeFamily>();
1043  st_maxdistance_sig.add(SqlTypeFamily.ANY);
1044  st_maxdistance_sig.add(SqlTypeFamily.ANY);
1045  return st_maxdistance_sig;
1046  }
1047  }
1048 
1049  static class ST_GeogFromText extends SqlFunction {
1051  super("ST_GeogFromText",
1052  SqlKind.OTHER_FUNCTION,
1053  null,
1054  null,
1055  OperandTypes.or(OperandTypes.family(SqlTypeFamily.ANY),
1056  OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER)),
1057  SqlFunctionCategory.SYSTEM);
1058  }
1059 
1060  @Override
1061  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1062  assert opBinding.getOperandCount() == 1;
1063  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1064  return typeFactory.createSqlType(SqlTypeName.INTEGER);
1065  }
1066  }
1067 
1068  static class ST_GeomFromText extends SqlFunction {
1070  super("ST_GeomFromText",
1071  SqlKind.OTHER_FUNCTION,
1072  null,
1073  null,
1074  OperandTypes.or(OperandTypes.family(SqlTypeFamily.ANY),
1075  OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER)),
1076  SqlFunctionCategory.SYSTEM);
1077  }
1078 
1079  @Override
1080  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1081  assert opBinding.getOperandCount() == 1;
1082  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1083  return typeFactory.createSqlType(SqlTypeName.INTEGER);
1084  }
1085  }
1086 
1087  static class ST_Transform extends SqlFunction {
1089  super("ST_Transform",
1090  SqlKind.OTHER_FUNCTION,
1091  null,
1092  null,
1093  OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER),
1094  SqlFunctionCategory.SYSTEM);
1095  }
1096 
1097  @Override
1098  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1099  assert opBinding.getOperandCount() == 1;
1100  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1101  return typeFactory.createTypeWithNullability(
1102  typeFactory.createSqlType(SqlTypeName.INTEGER),
1103  opBinding.getOperandType(0).isNullable());
1104  }
1105  }
1106 
1107  static class ST_X extends SqlFunction {
1108  ST_X() {
1109  super("ST_X",
1110  SqlKind.OTHER_FUNCTION,
1111  null,
1112  null,
1113  OperandTypes.family(SqlTypeFamily.ANY),
1114  SqlFunctionCategory.SYSTEM);
1115  }
1116 
1117  @Override
1118  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1119  assert opBinding.getOperandCount() == 1;
1120  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1121  return typeFactory.createTypeWithNullability(
1122  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1123  opBinding.getOperandType(0).isNullable());
1124  }
1125  }
1126 
1127  static class ST_Y extends SqlFunction {
1128  ST_Y() {
1129  super("ST_Y",
1130  SqlKind.OTHER_FUNCTION,
1131  null,
1132  null,
1133  OperandTypes.family(SqlTypeFamily.ANY),
1134  SqlFunctionCategory.SYSTEM);
1135  }
1136 
1137  @Override
1138  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1139  assert opBinding.getOperandCount() == 1;
1140  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1141  return typeFactory.createTypeWithNullability(
1142  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1143  opBinding.getOperandType(0).isNullable());
1144  }
1145  }
1146 
1147  static class ST_XMin extends SqlFunction {
1149  super("ST_XMin",
1150  SqlKind.OTHER_FUNCTION,
1151  null,
1152  null,
1153  OperandTypes.family(SqlTypeFamily.ANY),
1154  SqlFunctionCategory.SYSTEM);
1155  }
1156 
1157  @Override
1158  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1159  assert opBinding.getOperandCount() == 1;
1160  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1161  return typeFactory.createTypeWithNullability(
1162  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1163  opBinding.getOperandType(0).isNullable());
1164  }
1165  }
1166 
1167  static class ST_XMax extends SqlFunction {
1169  super("ST_XMax",
1170  SqlKind.OTHER_FUNCTION,
1171  null,
1172  null,
1173  OperandTypes.family(SqlTypeFamily.ANY),
1174  SqlFunctionCategory.SYSTEM);
1175  }
1176 
1177  @Override
1178  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1179  assert opBinding.getOperandCount() == 1;
1180  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1181  return typeFactory.createTypeWithNullability(
1182  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1183  opBinding.getOperandType(0).isNullable());
1184  }
1185  }
1186 
1187  static class ST_YMin extends SqlFunction {
1189  super("ST_YMin",
1190  SqlKind.OTHER_FUNCTION,
1191  null,
1192  null,
1193  OperandTypes.family(SqlTypeFamily.ANY),
1194  SqlFunctionCategory.SYSTEM);
1195  }
1196 
1197  @Override
1198  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1199  assert opBinding.getOperandCount() == 1;
1200  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1201  return typeFactory.createTypeWithNullability(
1202  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1203  opBinding.getOperandType(0).isNullable());
1204  }
1205  }
1206 
1207  static class ST_YMax extends SqlFunction {
1209  super("ST_YMax",
1210  SqlKind.OTHER_FUNCTION,
1211  null,
1212  null,
1213  OperandTypes.family(SqlTypeFamily.ANY),
1214  SqlFunctionCategory.SYSTEM);
1215  }
1216 
1217  @Override
1218  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1219  assert opBinding.getOperandCount() == 1;
1220  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1221  return typeFactory.createTypeWithNullability(
1222  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1223  opBinding.getOperandType(0).isNullable());
1224  }
1225  }
1226 
1227  static class ST_PointN extends SqlFunction {
1229  super("ST_PointN",
1230  SqlKind.OTHER_FUNCTION,
1231  null,
1232  null,
1233  OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER),
1234  SqlFunctionCategory.SYSTEM);
1235  }
1236 
1237  @Override
1238  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1239  assert opBinding.getOperandCount() == 1;
1240  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1241  return typeFactory.createTypeWithNullability(
1242  typeFactory.createSqlType(SqlTypeName.INTEGER),
1243  opBinding.getOperandType(0).isNullable());
1244  }
1245  }
1246 
1247  static class ST_EndPoint extends SqlFunction {
1249  super("ST_EndPoint",
1250  SqlKind.OTHER_FUNCTION,
1251  null,
1252  null,
1253  OperandTypes.family(SqlTypeFamily.ANY),
1254  SqlFunctionCategory.SYSTEM);
1255  }
1256 
1257  @Override
1258  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1259  assert opBinding.getOperandCount() == 1;
1260  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1261  return typeFactory.createTypeWithNullability(
1262  typeFactory.createSqlType(SqlTypeName.INTEGER),
1263  opBinding.getOperandType(0).isNullable());
1264  }
1265  }
1266 
1267  static class ST_StartPoint extends SqlFunction {
1269  super("ST_StartPoint",
1270  SqlKind.OTHER_FUNCTION,
1271  null,
1272  null,
1273  OperandTypes.family(SqlTypeFamily.ANY),
1274  SqlFunctionCategory.SYSTEM);
1275  }
1276 
1277  @Override
1278  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1279  assert opBinding.getOperandCount() == 1;
1280  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1281  return typeFactory.createTypeWithNullability(
1282  typeFactory.createSqlType(SqlTypeName.INTEGER),
1283  opBinding.getOperandType(0).isNullable());
1284  }
1285  }
1286 
1287  static class ST_Length extends SqlFunction {
1289  super("ST_Length",
1290  SqlKind.OTHER_FUNCTION,
1291  null,
1292  null,
1293  OperandTypes.family(SqlTypeFamily.ANY),
1294  SqlFunctionCategory.SYSTEM);
1295  }
1296 
1297  @Override
1298  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1299  assert opBinding.getOperandCount() == 1;
1300  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1301  return typeFactory.createTypeWithNullability(
1302  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1303  opBinding.getOperandType(0).isNullable());
1304  }
1305  }
1306 
1307  static class ST_Perimeter extends SqlFunction {
1309  super("ST_Perimeter",
1310  SqlKind.OTHER_FUNCTION,
1311  null,
1312  null,
1313  OperandTypes.family(SqlTypeFamily.ANY),
1314  SqlFunctionCategory.SYSTEM);
1315  }
1316 
1317  @Override
1318  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1319  assert opBinding.getOperandCount() == 1;
1320  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1321  return typeFactory.createTypeWithNullability(
1322  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1323  opBinding.getOperandType(0).isNullable());
1324  }
1325  }
1326 
1327  static class ST_Area extends SqlFunction {
1329  super("ST_Area",
1330  SqlKind.OTHER_FUNCTION,
1331  null,
1332  null,
1333  OperandTypes.family(SqlTypeFamily.ANY),
1334  SqlFunctionCategory.SYSTEM);
1335  }
1336 
1337  @Override
1338  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1339  assert opBinding.getOperandCount() == 1;
1340  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1341  return typeFactory.createTypeWithNullability(
1342  typeFactory.createSqlType(SqlTypeName.DOUBLE),
1343  opBinding.getOperandType(0).isNullable());
1344  }
1345  }
1346 
1347  static class ST_NPoints extends SqlFunction {
1349  super("ST_NPoints",
1350  SqlKind.OTHER_FUNCTION,
1351  null,
1352  null,
1353  OperandTypes.family(SqlTypeFamily.ANY),
1354  SqlFunctionCategory.SYSTEM);
1355  }
1356 
1357  @Override
1358  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1359  assert opBinding.getOperandCount() == 1;
1360  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1361  return typeFactory.createTypeWithNullability(
1362  typeFactory.createSqlType(SqlTypeName.INTEGER),
1363  opBinding.getOperandType(0).isNullable());
1364  }
1365  }
1366 
1367  static class ST_NRings extends SqlFunction {
1369  super("ST_NRings",
1370  SqlKind.OTHER_FUNCTION,
1371  null,
1372  null,
1373  OperandTypes.family(SqlTypeFamily.ANY),
1374  SqlFunctionCategory.SYSTEM);
1375  }
1376 
1377  @Override
1378  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1379  assert opBinding.getOperandCount() == 1;
1380  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1381  return typeFactory.createTypeWithNullability(
1382  typeFactory.createSqlType(SqlTypeName.INTEGER),
1383  opBinding.getOperandType(0).isNullable());
1384  }
1385  }
1386 
1387  static class ST_SRID extends SqlFunction {
1389  super("ST_SRID",
1390  SqlKind.OTHER_FUNCTION,
1391  null,
1392  null,
1393  OperandTypes.family(SqlTypeFamily.ANY),
1394  SqlFunctionCategory.SYSTEM);
1395  }
1396 
1397  @Override
1398  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1399  assert opBinding.getOperandCount() == 1;
1400  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1401  return typeFactory.createTypeWithNullability(
1402  typeFactory.createSqlType(SqlTypeName.INTEGER),
1403  opBinding.getOperandType(0).isNullable());
1404  }
1405  }
1406 
1407  static class ST_SetSRID extends SqlFunction {
1409  super("ST_SetSRID",
1410  SqlKind.OTHER_FUNCTION,
1411  null,
1412  null,
1413  OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER),
1414  SqlFunctionCategory.SYSTEM);
1415  }
1416 
1417  @Override
1418  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1419  assert opBinding.getOperandCount() == 1;
1420  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1421  return typeFactory.createTypeWithNullability(
1422  typeFactory.createSqlType(SqlTypeName.INTEGER),
1423  opBinding.getOperandType(0).isNullable());
1424  }
1425  }
1426 
1427  static class ST_Point extends SqlFunction {
1429  super("ST_Point",
1430  SqlKind.OTHER_FUNCTION,
1431  null,
1432  null,
1433  OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
1434  SqlFunctionCategory.SYSTEM);
1435  }
1436 
1437  @Override
1438  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1439  assert opBinding.getOperandCount() == 2;
1440  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1441  return typeFactory.createSqlType(SqlTypeName.INTEGER);
1442  }
1443  }
1444 
1445  static class CastToGeography extends SqlFunction {
1447  super("CastToGeography",
1448  SqlKind.OTHER_FUNCTION,
1449  null,
1450  null,
1451  OperandTypes.family(SqlTypeFamily.ANY),
1452  SqlFunctionCategory.SYSTEM);
1453  }
1454 
1455  @Override
1456  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1457  assert opBinding.getOperandCount() == 1;
1458  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1459  return typeFactory.createSqlType(SqlTypeName.INTEGER);
1460  }
1461  }
1462 
1463  /* OFFSET_IN_FRAGMENT() */
1464  public static class OffsetInFragment extends SqlFunction {
1465  public OffsetInFragment() {
1466  super("OFFSET_IN_FRAGMENT",
1467  SqlKind.OTHER_FUNCTION,
1468  null,
1469  null,
1470  OperandTypes.NILADIC,
1471  SqlFunctionCategory.SYSTEM);
1472  }
1473 
1474  @Override
1475  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1476  assert opBinding.getOperandCount() == 0;
1477  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1478  return typeFactory.createSqlType(SqlTypeName.INTEGER);
1479  }
1480  }
1481 
1482  static class ApproxCountDistinct extends SqlAggFunction {
1484  super("APPROX_COUNT_DISTINCT",
1485  null,
1486  SqlKind.OTHER_FUNCTION,
1487  null,
1488  null,
1489  OperandTypes.or(OperandTypes.family(SqlTypeFamily.ANY),
1490  OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER)),
1491  SqlFunctionCategory.SYSTEM);
1492  }
1493 
1494  @Override
1495  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1496  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1497  return typeFactory.createSqlType(SqlTypeName.BIGINT);
1498  }
1499  }
1500 
1501  static class MapDAvg extends SqlAggFunction {
1503  super("AVG",
1504  null,
1505  SqlKind.OTHER_FUNCTION,
1506  null,
1507  null,
1508  OperandTypes.family(SqlTypeFamily.NUMERIC),
1509  SqlFunctionCategory.SYSTEM);
1510  }
1511 
1512  @Override
1513  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1514  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1515  return typeFactory.createSqlType(SqlTypeName.DOUBLE);
1516  }
1517  }
1518 
1519  public static class Sample extends SqlAggFunction {
1520  public Sample() {
1521  super("SAMPLE",
1522  SqlKind.OTHER_FUNCTION,
1523  null,
1524  null,
1525  OperandTypes.ANY,
1526  SqlFunctionCategory.SYSTEM);
1527  }
1528 
1529  @Override
1530  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1531  return opBinding.getOperandType(0);
1532  }
1533  }
1534 
1535  // for backwards compatibility
1536  public static class LastSample extends SqlAggFunction {
1537  public LastSample() {
1538  super("LAST_SAMPLE",
1539  SqlKind.OTHER_FUNCTION,
1540  null,
1541  null,
1542  OperandTypes.ANY,
1543  SqlFunctionCategory.SYSTEM);
1544  }
1545 
1546  @Override
1547  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1548  return opBinding.getOperandType(0);
1549  }
1550  }
1551 
1552  static class ExtFunction extends SqlFunction {
1553  ExtFunction(final String name, final ExtensionFunction sig) {
1554  super(name,
1555  SqlKind.OTHER_FUNCTION,
1556  null,
1557  null,
1558  OperandTypes.family(toSqlSignature(sig)),
1559  sig.isRowUdf() ? SqlFunctionCategory.SYSTEM
1560  : SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
1561  isRowUdf = sig.isRowUdf();
1562  if (isRowUdf) {
1563  ret = toSqlTypeName(sig.getRet());
1564  } else {
1565  ret = null;
1566  }
1567  }
1568 
1569  private static java.util.List<SqlTypeFamily> toSqlSignature(
1570  final ExtensionFunction sig) {
1571  java.util.List<SqlTypeFamily> sql_sig = new java.util.ArrayList<SqlTypeFamily>();
1572  boolean isRowUdf = sig.isRowUdf();
1573  for (int arg_idx = 0; arg_idx < sig.getArgs().size(); ++arg_idx) {
1574  final ExtensionFunction.ExtArgumentType arg_type = sig.getArgs().get(arg_idx);
1575  if (isRowUdf) {
1576  sql_sig.add(toSqlTypeName(arg_type).getFamily());
1577  if (isPointerType(arg_type)) {
1578  ++arg_idx;
1579  }
1580  } else {
1581  if (isPointerType(arg_type)) {
1582  /* TODO: eliminate using getValueType */
1583  sql_sig.add(toSqlTypeName(getValueType(arg_type)).getFamily());
1584  } else {
1585  sql_sig.add(toSqlTypeName(arg_type).getFamily());
1586  }
1587  }
1588  }
1589  return sql_sig;
1590  }
1591 
1592  private static boolean isPointerType(final ExtensionFunction.ExtArgumentType type) {
1600  }
1601 
1602  @Override
1603  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1604  if (isRowUdf) {
1605  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1606  return typeFactory.createTypeWithNullability(
1607  typeFactory.createSqlType(ret), true);
1608  } else {
1609  assert opBinding.getOperandCount() == 2;
1610  return opBinding.getCursorOperand(0);
1611  }
1612  }
1613 
1616  switch (type) {
1617  case PInt8:
1619  case PInt16:
1621  case PInt32:
1623  case PInt64:
1625  case PFloat:
1627  case PDouble:
1629  case PBool:
1631  }
1632  MAPDLOGGER.error("getValueType: no value for type " + type);
1633  assert false;
1634  return null;
1635  }
1636 
1637  private static SqlTypeName toSqlTypeName(
1639  switch (type) {
1640  case Bool:
1641  return SqlTypeName.BOOLEAN;
1642  case Int8:
1643  return SqlTypeName.TINYINT;
1644  case Int16:
1645  return SqlTypeName.SMALLINT;
1646  case Int32:
1647  return SqlTypeName.INTEGER;
1648  case Int64:
1649  return SqlTypeName.BIGINT;
1650  case Float:
1651  return SqlTypeName.FLOAT;
1652  case Double:
1653  return SqlTypeName.DOUBLE;
1654  case PInt8:
1655  case PInt16:
1656  case PInt32:
1657  case PInt64:
1658  case PFloat:
1659  case PDouble:
1660  case PBool:
1661  case ArrayInt8:
1662  case ArrayInt16:
1663  case ArrayInt32:
1664  case ArrayInt64:
1665  case ArrayFloat:
1666  case ArrayDouble:
1667  case ArrayBool:
1668  return SqlTypeName.ARRAY;
1669  case GeoPoint:
1670  case GeoLineString:
1671  case GeoPolygon:
1672  case GeoMultiPolygon:
1673  return SqlTypeName.GEOMETRY;
1674  case Cursor:
1675  return SqlTypeName.CURSOR;
1676  }
1677  MAPDLOGGER.error("toSqlTypeName: unknown type " + type);
1678  assert false;
1679  return null;
1680  }
1681  private final boolean isRowUdf;
1682  private final SqlTypeName ret;
1683  }
1684 
1685  //
1686  // Internal accessors for in-situ poly render queries
1687  //
1688  // The MapD_* varietals are deprecated. The OmniSci_Geo_* ones should be used
1689  // instead
1690  //
1691 
1692  static class MapD_GeoPolyBoundsPtr extends SqlFunction {
1694  super("MapD_GeoPolyBoundsPtr",
1695  SqlKind.OTHER_FUNCTION,
1696  null,
1697  null,
1698  OperandTypes.family(SqlTypeFamily.ANY),
1699  SqlFunctionCategory.SYSTEM);
1700  }
1701 
1702  @Override
1703  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1704  assert opBinding.getOperandCount() == 1;
1705  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1706  return typeFactory.createSqlType(SqlTypeName.BIGINT);
1707  }
1708  }
1709 
1710  static class MapD_GeoPolyRenderGroup extends SqlFunction {
1712  super("MapD_GeoPolyRenderGroup",
1713  SqlKind.OTHER_FUNCTION,
1714  null,
1715  null,
1716  OperandTypes.family(SqlTypeFamily.ANY),
1717  SqlFunctionCategory.SYSTEM);
1718  }
1719 
1720  @Override
1721  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1722  assert opBinding.getOperandCount() == 1;
1723  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1724  return typeFactory.createSqlType(SqlTypeName.INTEGER);
1725  }
1726  }
1727 
1728  static class OmniSci_Geo_PolyBoundsPtr extends SqlFunction {
1730  super("OmniSci_Geo_PolyBoundsPtr",
1731  SqlKind.OTHER_FUNCTION,
1732  null,
1733  null,
1734  OperandTypes.family(SqlTypeFamily.ANY),
1735  SqlFunctionCategory.SYSTEM);
1736  }
1737 
1738  @Override
1739  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1740  assert opBinding.getOperandCount() == 1;
1741  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1742  return typeFactory.createSqlType(SqlTypeName.BIGINT);
1743  }
1744  }
1745 
1746  static class OmniSci_Geo_PolyRenderGroup extends SqlFunction {
1748  super("OmniSci_Geo_PolyRenderGroup",
1749  SqlKind.OTHER_FUNCTION,
1750  null,
1751  null,
1752  OperandTypes.family(SqlTypeFamily.ANY),
1753  SqlFunctionCategory.SYSTEM);
1754  }
1755 
1756  @Override
1757  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1758  assert opBinding.getOperandCount() == 1;
1759  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1760  return typeFactory.createSqlType(SqlTypeName.INTEGER);
1761  }
1762  }
1763 
1764  static class convert_meters_to_pixel_width extends SqlFunction {
1766  super("convert_meters_to_pixel_width",
1767  SqlKind.OTHER_FUNCTION,
1768  null,
1769  null,
1770  OperandTypes.family(SqlTypeFamily.NUMERIC,
1771  SqlTypeFamily.ANY,
1772  SqlTypeFamily.NUMERIC,
1773  SqlTypeFamily.NUMERIC,
1774  SqlTypeFamily.NUMERIC,
1775  SqlTypeFamily.NUMERIC),
1776  SqlFunctionCategory.SYSTEM);
1777  }
1778 
1779  @Override
1780  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1781  assert opBinding.getOperandCount() == 6;
1782  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1783  return typeFactory.createSqlType(SqlTypeName.DOUBLE);
1784  }
1785  }
1786 
1787  static class convert_meters_to_pixel_height extends SqlFunction {
1789  super("convert_meters_to_pixel_height",
1790  SqlKind.OTHER_FUNCTION,
1791  null,
1792  null,
1793  OperandTypes.family(SqlTypeFamily.NUMERIC,
1794  SqlTypeFamily.ANY,
1795  SqlTypeFamily.NUMERIC,
1796  SqlTypeFamily.NUMERIC,
1797  SqlTypeFamily.NUMERIC,
1798  SqlTypeFamily.NUMERIC),
1799  SqlFunctionCategory.SYSTEM);
1800  }
1801 
1802  @Override
1803  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1804  assert opBinding.getOperandCount() == 6;
1805  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1806  return typeFactory.createSqlType(SqlTypeName.DOUBLE);
1807  }
1808  }
1809 
1810  static class is_point_in_view extends SqlFunction {
1812  super("is_point_in_view",
1813  SqlKind.OTHER_FUNCTION,
1814  null,
1815  null,
1816  OperandTypes.family(SqlTypeFamily.ANY,
1817  SqlTypeFamily.NUMERIC,
1818  SqlTypeFamily.NUMERIC,
1819  SqlTypeFamily.NUMERIC,
1820  SqlTypeFamily.NUMERIC),
1821  SqlFunctionCategory.SYSTEM);
1822  }
1823 
1824  @Override
1825  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1826  assert opBinding.getOperandCount() == 5;
1827  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1828  return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
1829  }
1830  }
1831 
1832  static class is_point_size_in_view extends SqlFunction {
1834  super("is_point_size_in_view",
1835  SqlKind.OTHER_FUNCTION,
1836  null,
1837  null,
1838  OperandTypes.family(SqlTypeFamily.ANY,
1839  SqlTypeFamily.NUMERIC,
1840  SqlTypeFamily.NUMERIC,
1841  SqlTypeFamily.NUMERIC,
1842  SqlTypeFamily.NUMERIC,
1843  SqlTypeFamily.NUMERIC),
1844  SqlFunctionCategory.SYSTEM);
1845  }
1846 
1847  @Override
1848  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1849  assert opBinding.getOperandCount() == 6;
1850  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1851  return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
1852  }
1853  }
1854 
1855  public static class usTimestamp extends SqlFunction {
1856  public usTimestamp() {
1857  super("usTIMESTAMP",
1858  SqlKind.OTHER_FUNCTION,
1859  null,
1860  null,
1861  OperandTypes.STRING,
1862  SqlFunctionCategory.SYSTEM);
1863  }
1864 
1865  @Override
1866  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1867  assert opBinding.getOperandCount() == 1;
1868  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1869  return typeFactory.createSqlType(SqlTypeName.TIMESTAMP, 6);
1870  }
1871  }
1872 
1873  public static class nsTimestamp extends SqlFunction {
1874  public nsTimestamp() {
1875  super("nsTIMESTAMP",
1876  SqlKind.OTHER_FUNCTION,
1877  null,
1878  null,
1879  OperandTypes.STRING,
1880  SqlFunctionCategory.SYSTEM);
1881  }
1882 
1883  @Override
1884  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
1885  assert opBinding.getOperandCount() == 1;
1886  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
1887  return typeFactory.createSqlType(SqlTypeName.TIMESTAMP, 9);
1888  }
1889  }
1890 }
1891 
1892 // End MapDSqlOperatorTable.java
RelDataType inferReturnType(SqlOperatorBinding opBinding)
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)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static boolean isPointerType(final ExtensionFunction.ExtArgumentType type)
ExtFunction(final String name, final ExtensionFunction sig)
static java.util.List< SqlTypeFamily > signature()
EXTENSION_INLINE int32_t OmniSci_Geo_PolyRenderGroup(int32_t render_group)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
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)
static java.util.List< SqlTypeFamily > signature()
static java.util.List< SqlTypeFamily > getSignatureFamilies()
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)
EXTENSION_NOINLINE double ST_YMax(int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
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 > 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)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
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)
EXTENSION_INLINE int32_t MapD_GeoPolyRenderGroup(int32_t render_group)
EXTENSION_INLINE int64_t OmniSci_Geo_PolyBoundsPtr(double *bounds, int64_t size)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static SqlTypeName toSqlTypeName(final ExtensionFunction.ExtArgumentType type)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_NOINLINE double ST_YMin(int8_t *coords, int64_t size, int32_t ic, int32_t isr, int32_t osr)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_INLINE int64_t MapD_GeoPolyBoundsPtr(double *bounds, int64_t size)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
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)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
RelDataType getComponentType(RelDataTypeFactory typeFactory, List< RelDataType > argTypes)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > signature()
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static java.util.List< SqlTypeFamily > toSqlSignature(final ExtensionFunction sig)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_INLINE int32_t ST_NRings(int32_t *poly_ring_sizes, int64_t poly_num_rings)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_NOINLINE double Truncate(const double x, const int32_t y)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static void addUDF(MapDSqlOperatorTable opTab, final Map< String, ExtensionFunction > extSigs)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
static ExtensionFunction.ExtArgumentType getValueType(final ExtensionFunction.ExtArgumentType type)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
EXTENSION_INLINE int32_t ST_NPoints(int8_t *coords, int64_t coords_sz, int32_t ic)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
RelDataType inferReturnType(SqlOperatorBinding opBinding)
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)