OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CalciteServerHandler.java
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, 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 
17 package com.mapd.parser.server;
18 
19 import static com.mapd.calcite.parser.HeavyDBParser.CURRENT_PARSER;
20 
25 
29 import org.apache.calcite.runtime.CalciteContextException;
30 import org.apache.calcite.sql.SqlNode;
31 import org.apache.calcite.sql.parser.SqlParseException;
32 import org.apache.calcite.sql.type.SqlTypeName;
33 import org.apache.calcite.sql.validate.SqlMoniker;
34 import org.apache.calcite.sql.validate.SqlMonikerType;
35 import org.apache.calcite.tools.RelConversionException;
36 import org.apache.calcite.tools.ValidationException;
37 import org.apache.calcite.util.Pair;
38 import org.apache.commons.pool.PoolableObjectFactory;
39 import org.apache.commons.pool.impl.GenericObjectPool;
40 import org.apache.thrift.TException;
41 import org.apache.thrift.server.TServer;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
44 
45 import java.io.IOException;
46 import java.util.ArrayList;
47 import java.util.Arrays;
48 import java.util.HashMap;
49 import java.util.List;
50 import java.util.Map;
51 import java.util.stream.Collectors;
52 
53 import ai.heavy.thrift.calciteserver.CalciteServer;
54 import ai.heavy.thrift.calciteserver.InvalidParseRequest;
55 import ai.heavy.thrift.calciteserver.TAccessedQueryObjects;
56 import ai.heavy.thrift.calciteserver.TCompletionHint;
57 import ai.heavy.thrift.calciteserver.TCompletionHintType;
58 import ai.heavy.thrift.calciteserver.TExtArgumentType;
59 import ai.heavy.thrift.calciteserver.TFilterPushDownInfo;
60 import ai.heavy.thrift.calciteserver.TOptimizationOption;
61 import ai.heavy.thrift.calciteserver.TPlanResult;
62 import ai.heavy.thrift.calciteserver.TQueryParsingOption;
63 import ai.heavy.thrift.calciteserver.TRestriction;
64 import ai.heavy.thrift.calciteserver.TUserDefinedFunction;
65 import ai.heavy.thrift.calciteserver.TUserDefinedTableFunction;
66 
67 public class CalciteServerHandler implements CalciteServer.Iface {
68  final static Logger HEAVYDBLOGGER = LoggerFactory.getLogger(CalciteServerHandler.class);
69  private TServer server;
70 
71  private final int dbPort;
72 
73  private volatile long callCount;
74 
75  private final GenericObjectPool parserPool;
76 
78 
79  private final String extSigsJson;
80 
81  private final String udfSigsJson;
82 
83  private String udfRTSigsJson = "";
84  Map<String, ExtensionFunction> udfRTSigs = null;
85 
86  Map<String, ExtensionFunction> udtfSigs = null;
87 
89  private Map<String, ExtensionFunction> extSigs = null;
90  private String dataDir;
91 
92  // TODO MAT we need to merge this into common code base for these functions with
93  // CalciteDirect since we are not deprecating this stuff yet
95  String dataDir,
96  String extensionFunctionsAstFile,
98  String udfAstFile) {
99  this.dbPort = dbPort;
100  this.dataDir = dataDir;
101 
102  Map<String, ExtensionFunction> udfSigs = null;
103 
104  try {
105  extSigs = ExtensionFunctionSignatureParser.parse(extensionFunctionsAstFile);
106  } catch (IOException ex) {
107  HEAVYDBLOGGER.error(
108  "Could not load extension function signatures: " + ex.getMessage(), ex);
109  }
110  extSigsJson = ExtensionFunctionSignatureParser.signaturesToJson(extSigs);
111 
112  try {
113  if (!udfAstFile.isEmpty()) {
114  udfSigs = ExtensionFunctionSignatureParser.parseUdfAst(udfAstFile);
115  }
116  } catch (IOException ex) {
117  HEAVYDBLOGGER.error(
118  "Could not load udf function signatures: " + ex.getMessage(), ex);
119  }
120  udfSigsJson = ExtensionFunctionSignatureParser.signaturesToJson(udfSigs);
121 
122  // Put all the udf functions signatures in extSigs so Calcite has a view of
123  // extension functions and udf functions
124  if (!udfAstFile.isEmpty()) {
125  extSigs.putAll(udfSigs);
126  }
127 
128  calciteParserFactory = new CalciteParserFactory(dataDir, extSigs, dbPort, skT);
129 
130  // GenericObjectPool::setFactory is deprecated
131  this.parserPool = new GenericObjectPool(calciteParserFactory);
132  }
133 
134  @Override
135  public void ping() throws TException {
136  HEAVYDBLOGGER.debug("Ping hit");
137  }
138 
139  @Override
140  public TPlanResult process(String user,
141  String session,
142  String catalog,
143  String queryText,
144  TQueryParsingOption queryParsingOption,
145  TOptimizationOption optimizationOption,
146  List<TRestriction> trestrictions) throws InvalidParseRequest, TException {
147  long timer = System.currentTimeMillis();
148  callCount++;
149 
151  try {
152  parser = (HeavyDBParser) parserPool.borrowObject();
153  parser.clearMemo();
154  } catch (Exception ex) {
155  String msg = "Could not get Parse Item from pool: " + ex.getMessage();
156  HEAVYDBLOGGER.error(msg, ex);
157  throw new InvalidParseRequest(-1, msg);
158  }
159  List<Restriction> rests = null;
160  if (trestrictions != null && !trestrictions.isEmpty()) {
161  rests = new ArrayList<>();
162  for (TRestriction trestriction : trestrictions) {
163  Restriction rest = null;
164  rest = new Restriction(trestriction.database,
165  trestriction.table,
166  trestriction.column,
167  trestriction.values);
168  rests.add(rest);
169  }
170  }
171  HeavyDBUser dbUser = new HeavyDBUser(user, session, catalog, dbPort, rests);
172  HEAVYDBLOGGER.debug("process was called User: " + user + " Catalog: " + catalog
173  + " sql: " + queryText);
174  parser.setUser(dbUser);
175  CURRENT_PARSER.set(parser);
176 
177  // this code path is introduced to execute a query for intel-modin project
178  // they appended a special prefix "execute calcite" to distinguish their usage
179  boolean buildRATreeFromRAString = false;
180  if (queryText.startsWith("execute calcite")) {
181  queryText = queryText.replaceFirst("execute calcite", "");
182  buildRATreeFromRAString = true;
183  }
184 
185  // need to trim the sql string as it seems it is not trimed prior to here
186  queryText = queryText.trim();
187  // remove last charcter if it is a ;
188  if (queryText.length() > 0 && queryText.charAt(queryText.length() - 1) == ';') {
189  queryText = queryText.substring(0, queryText.length() - 1);
190  }
191  String jsonResult;
192  SqlIdentifierCapturer capturer;
193  TAccessedQueryObjects primaryAccessedObjects = new TAccessedQueryObjects();
194  TAccessedQueryObjects resolvedAccessedObjects = new TAccessedQueryObjects();
195  try {
196  final List<HeavyDBParserOptions.FilterPushDownInfo> filterPushDownInfo =
197  new ArrayList<>();
198  for (final TFilterPushDownInfo req : optimizationOption.filter_push_down_info) {
199  filterPushDownInfo.add(new HeavyDBParserOptions.FilterPushDownInfo(
200  req.input_prev, req.input_start, req.input_next));
201  }
202  HeavyDBParserOptions parserOptions = new HeavyDBParserOptions(filterPushDownInfo,
203  queryParsingOption.legacy_syntax,
204  queryParsingOption.is_explain,
205  optimizationOption.is_view_optimize,
206  optimizationOption.enable_watchdog,
207  optimizationOption.distributed_mode);
208 
209  if (!buildRATreeFromRAString) {
210  Pair<String, SqlIdentifierCapturer> res;
211  SqlNode node;
212 
213  res = parser.process(queryText, parserOptions);
214  jsonResult = res.left;
215  capturer = res.right;
216 
217  primaryAccessedObjects.tables_selected_from = new ArrayList<>(capturer.selects);
218  primaryAccessedObjects.tables_inserted_into = new ArrayList<>(capturer.inserts);
219  primaryAccessedObjects.tables_updated_in = new ArrayList<>(capturer.updates);
220  primaryAccessedObjects.tables_deleted_from = new ArrayList<>(capturer.deletes);
221 
222  // also resolve all the views in the select part
223  // resolution of the other parts is not
224  // necessary as these cannot be views
225  resolvedAccessedObjects.tables_selected_from =
226  new ArrayList<>(parser.resolveSelectIdentifiers(capturer));
227  resolvedAccessedObjects.tables_inserted_into = new ArrayList<>(capturer.inserts);
228  resolvedAccessedObjects.tables_updated_in = new ArrayList<>(capturer.updates);
229  resolvedAccessedObjects.tables_deleted_from = new ArrayList<>(capturer.deletes);
230 
231  } else {
232  // exploit Calcite's query optimization rules for RA string
233  jsonResult =
234  parser.buildRATreeAndPerformQueryOptimization(queryText, parserOptions);
235  }
236  } catch (SqlParseException ex) {
237  String msg = "SQL Error: " + ex.getMessage();
238  HEAVYDBLOGGER.error(msg);
239  throw new InvalidParseRequest(-2, msg);
240  } catch (org.apache.calcite.tools.ValidationException ex) {
241  String msg = "SQL Error: " + ex.getMessage();
242  if (ex.getCause() != null
243  && (ex.getCause().getClass() == CalciteContextException.class)) {
244  msg = "SQL Error: " + ex.getCause().getMessage();
245  }
246  HEAVYDBLOGGER.error(msg);
247  throw new InvalidParseRequest(-3, msg);
248  } catch (CalciteContextException ex) {
249  String msg = ex.getMessage();
250  HEAVYDBLOGGER.error(msg);
251  throw new InvalidParseRequest(-6, msg);
252  } catch (RelConversionException ex) {
253  String msg = "Failed to generate relational algebra for query " + ex.getMessage();
254  HEAVYDBLOGGER.error(msg, ex);
255  throw new InvalidParseRequest(-5, msg);
256  } catch (Throwable ex) {
257  HEAVYDBLOGGER.error(ex.getClass().toString());
258  String msg = ex.getMessage();
259  HEAVYDBLOGGER.error(msg, ex);
260  throw new InvalidParseRequest(-4, msg);
261  } finally {
262  CURRENT_PARSER.set(null);
263  try {
264  // put parser object back in pool for others to use
265  parserPool.returnObject(parser);
266  } catch (Exception ex) {
267  String msg = "Could not return parse object: " + ex.getMessage();
268  HEAVYDBLOGGER.error(msg, ex);
269  throw new InvalidParseRequest(-7, msg);
270  }
271  }
272 
273  TPlanResult result = new TPlanResult();
274  result.primary_accessed_objects = primaryAccessedObjects;
275  result.resolved_accessed_objects = resolvedAccessedObjects;
276  result.plan_result = jsonResult;
277  result.execution_time_ms = System.currentTimeMillis() - timer;
278 
279  return result;
280  }
281 
282  @Override
283  public void shutdown() throws TException {
284  // received request to shutdown
285  HEAVYDBLOGGER.debug("Shutdown calcite java server");
286  server.stop();
287  }
288 
289  @Override
291  return this.extSigsJson;
292  }
293 
294  @Override
296  return this.udfSigsJson;
297  }
298 
299  @Override
301  return this.udfRTSigsJson;
302  }
303 
304  void setServer(TServer s) {
305  server = s;
306  }
307 
308  @Override
309  public void updateMetadata(String catalog, String table) throws TException {
310  HEAVYDBLOGGER.debug(
311  "Received invalidation from server for " + catalog + " : " + table);
312  long timer = System.currentTimeMillis();
313  callCount++;
315  try {
316  parser = (HeavyDBParser) parserPool.borrowObject();
317  } catch (Exception ex) {
318  String msg = "Could not get Parse Item from pool: " + ex.getMessage();
319  HEAVYDBLOGGER.error(msg, ex);
320  return;
321  }
322  CURRENT_PARSER.set(parser);
323  try {
324  parser.updateMetaData(catalog, table);
325  } finally {
326  CURRENT_PARSER.set(null);
327  try {
328  // put parser object back in pool for others to use
329  HEAVYDBLOGGER.debug("Returning object to pool");
330  parserPool.returnObject(parser);
331  } catch (Exception ex) {
332  String msg = "Could not return parse object: " + ex.getMessage();
333  HEAVYDBLOGGER.error(msg, ex);
334  }
335  }
336  }
337 
338  @Override
339  public List<TCompletionHint> getCompletionHints(String user,
340  String session,
341  String catalog,
342  List<String> visible_tables,
343  String sql,
344  int cursor) throws TException {
345  callCount++;
347  try {
348  parser = (HeavyDBParser) parserPool.borrowObject();
349  } catch (Exception ex) {
350  String msg = "Could not get Parse Item from pool: " + ex.getMessage();
351  HEAVYDBLOGGER.error(msg, ex);
352  throw new TException(msg);
353  }
354  HeavyDBUser dbUser = new HeavyDBUser(user, session, catalog, dbPort, null);
355  HEAVYDBLOGGER.debug("getCompletionHints was called User: " + user
356  + " Catalog: " + catalog + " sql: " + sql);
357  parser.setUser(dbUser);
358  CURRENT_PARSER.set(parser);
359 
360  HeavyDBPlanner.CompletionResult completion_result;
361  try {
362  completion_result = parser.getCompletionHints(sql, cursor, visible_tables);
363  } catch (Exception ex) {
364  String msg = "Could not retrieve completion hints: " + ex.getMessage();
365  HEAVYDBLOGGER.error(msg, ex);
366  return new ArrayList<>();
367  } finally {
368  CURRENT_PARSER.set(null);
369  try {
370  // put parser object back in pool for others to use
371  parserPool.returnObject(parser);
372  } catch (Exception ex) {
373  String msg = "Could not return parse object: " + ex.getMessage();
374  HEAVYDBLOGGER.error(msg, ex);
375  throw new InvalidParseRequest(-4, msg);
376  }
377  }
378  List<TCompletionHint> result = new ArrayList<>();
379  for (final SqlMoniker hint : completion_result.hints) {
380  result.add(new TCompletionHint(hintTypeToThrift(hint.getType()),
381  hint.getFullyQualifiedNames(),
382  completion_result.replaced));
383  }
384  return result;
385  }
386 
387  @Override
388  public void setRuntimeExtensionFunctions(List<TUserDefinedFunction> udfs,
389  List<TUserDefinedTableFunction> udtfs,
390  boolean isruntime) {
391  if (isruntime) {
392  // Clean up previously defined Runtime UDFs
393  if (udfRTSigs != null) {
394  for (String name : udfRTSigs.keySet()) extSigs.remove(name);
395  udfRTSigsJson = "";
396  udfRTSigs.clear();
397  } else {
398  udfRTSigs = new HashMap<String, ExtensionFunction>();
399  }
400 
401  for (TUserDefinedFunction udf : udfs) {
402  udfRTSigs.put(udf.name, toExtensionFunction(udf, isruntime));
403  }
404 
405  for (TUserDefinedTableFunction udtf : udtfs) {
406  udfRTSigs.put(udtf.name, toExtensionFunction(udtf, isruntime));
407  }
408 
409  // Avoid overwritting compiled and Loadtime UDFs:
410  for (String name : udfRTSigs.keySet()) {
411  if (extSigs.containsKey(name)) {
412  HEAVYDBLOGGER.error("Extension function `" + name
413  + "` exists. Skipping runtime extenension function with the same name.");
414  udfRTSigs.remove(name);
415  }
416  }
417  // udfRTSigsJson will contain only the signatures of UDFs:
418  udfRTSigsJson = ExtensionFunctionSignatureParser.signaturesToJson(udfRTSigs);
419  // Expose RT UDFs to Calcite server:
420  extSigs.putAll(udfRTSigs);
421  } else {
422  // currently only LoadTime UDTFs can be registered via calcite thrift interface
423  if (udtfSigs == null) {
424  udtfSigs = new HashMap<String, ExtensionFunction>();
425  }
426 
427  for (TUserDefinedTableFunction udtf : udtfs) {
428  udtfSigs.put(udtf.name, toExtensionFunction(udtf, isruntime));
429  }
430 
431  extSigs.putAll(udtfSigs);
432  }
433 
434  calciteParserFactory.updateOperatorTable();
435  }
436 
438  TUserDefinedFunction udf, boolean isruntime) {
439  List<ExtensionFunction.ExtArgumentType> args =
440  new ArrayList<ExtensionFunction.ExtArgumentType>();
441  for (TExtArgumentType atype : udf.argTypes) {
442  final ExtensionFunction.ExtArgumentType arg_type = toExtArgumentType(atype);
443  if (arg_type != ExtensionFunction.ExtArgumentType.Void) {
444  args.add(arg_type);
445  }
446  }
447  return new ExtensionFunction(args, toExtArgumentType(udf.retType));
448  }
449 
451  TUserDefinedTableFunction udtf, boolean isruntime) {
452  int sqlInputArgIdx = 0;
453  int inputArgIdx = 0;
454  int outputArgIdx = 0;
455  List<String> names = new ArrayList<String>();
456  List<ExtensionFunction.ExtArgumentType> args = new ArrayList<>();
457  Map<String, List<ExtensionFunction.ExtArgumentType>> cursor_field_types =
458  new HashMap<>();
459  for (TExtArgumentType atype : udtf.sqlArgTypes) {
460  args.add(toExtArgumentType(atype));
461  Map<String, String> annot = udtf.annotations.get(sqlInputArgIdx);
462  String name = annot.getOrDefault("name", "inp" + sqlInputArgIdx);
463  if (atype == TExtArgumentType.Cursor) {
464  String field_names_annot = annot.getOrDefault("fields", "");
465  List<ExtensionFunction.ExtArgumentType> field_types = new ArrayList<>();
466  if (field_names_annot.length() > 0) {
467  String[] field_names =
468  field_names_annot.substring(1, field_names_annot.length() - 1)
469  .split(",");
470  for (int i = 0; i < field_names.length; i++) {
471  field_types.add(
472  toExtArgumentType(udtf.getInputArgTypes().get(inputArgIdx++)));
473  }
474  } else {
475  if (!isruntime) {
476  field_types.add(
477  toExtArgumentType(udtf.getInputArgTypes().get(inputArgIdx++)));
478  }
479  }
480  name = name + field_names_annot;
481  cursor_field_types.put(name, field_types);
482  } else {
483  inputArgIdx++;
484  }
485  names.add(name);
486  sqlInputArgIdx++;
487  }
488 
489  List<ExtensionFunction.ExtArgumentType> outs = new ArrayList<>();
490  for (TExtArgumentType otype : udtf.outputArgTypes) {
491  outs.add(toExtArgumentType(otype));
492  Map<String, String> annot = udtf.annotations.get(sqlInputArgIdx);
493  names.add(annot.getOrDefault("name", "out" + outputArgIdx));
494  sqlInputArgIdx++;
495  outputArgIdx++;
496  }
497  return new ExtensionFunction(args,
498  outs,
499  names,
500  udtf.annotations.get(udtf.annotations.size() - 1),
501  cursor_field_types);
502  }
503 
504  private static ExtensionFunction.ExtArgumentType toExtArgumentType(
505  TExtArgumentType type) {
506  switch (type) {
507  case Int8:
508  return ExtensionFunction.ExtArgumentType.Int8;
509  case Int16:
510  return ExtensionFunction.ExtArgumentType.Int16;
511  case Int32:
512  return ExtensionFunction.ExtArgumentType.Int32;
513  case Int64:
514  return ExtensionFunction.ExtArgumentType.Int64;
515  case Float:
516  return ExtensionFunction.ExtArgumentType.Float;
517  case Double:
519  case Void:
520  return ExtensionFunction.ExtArgumentType.Void;
521  case PInt8:
522  return ExtensionFunction.ExtArgumentType.PInt8;
523  case PInt16:
524  return ExtensionFunction.ExtArgumentType.PInt16;
525  case PInt32:
526  return ExtensionFunction.ExtArgumentType.PInt32;
527  case PInt64:
528  return ExtensionFunction.ExtArgumentType.PInt64;
529  case PFloat:
530  return ExtensionFunction.ExtArgumentType.PFloat;
531  case PDouble:
532  return ExtensionFunction.ExtArgumentType.PDouble;
533  case PBool:
534  return ExtensionFunction.ExtArgumentType.PBool;
535  case Bool:
536  return ExtensionFunction.ExtArgumentType.Bool;
537  case ArrayInt8:
538  return ExtensionFunction.ExtArgumentType.ArrayInt8;
539  case ArrayInt16:
540  return ExtensionFunction.ExtArgumentType.ArrayInt16;
541  case ArrayInt32:
542  return ExtensionFunction.ExtArgumentType.ArrayInt32;
543  case ArrayInt64:
544  return ExtensionFunction.ExtArgumentType.ArrayInt64;
545  case ArrayFloat:
546  return ExtensionFunction.ExtArgumentType.ArrayFloat;
547  case ArrayDouble:
548  return ExtensionFunction.ExtArgumentType.ArrayDouble;
549  case ArrayBool:
550  return ExtensionFunction.ExtArgumentType.ArrayBool;
552  return ExtensionFunction.ExtArgumentType.ArrayTextEncodingDict;
553  case ColumnInt8:
554  return ExtensionFunction.ExtArgumentType.ColumnInt8;
555  case ColumnInt16:
556  return ExtensionFunction.ExtArgumentType.ColumnInt16;
557  case ColumnInt32:
558  return ExtensionFunction.ExtArgumentType.ColumnInt32;
559  case ColumnInt64:
560  return ExtensionFunction.ExtArgumentType.ColumnInt64;
561  case ColumnFloat:
562  return ExtensionFunction.ExtArgumentType.ColumnFloat;
563  case ColumnDouble:
564  return ExtensionFunction.ExtArgumentType.ColumnDouble;
565  case ColumnBool:
566  return ExtensionFunction.ExtArgumentType.ColumnBool;
568  return ExtensionFunction.ExtArgumentType.ColumnTextEncodingDict;
569  case ColumnTimestamp:
570  return ExtensionFunction.ExtArgumentType.ColumnTimestamp;
571  case GeoPoint:
572  return ExtensionFunction.ExtArgumentType.GeoPoint;
573  case GeoMultiPoint:
574  return ExtensionFunction.ExtArgumentType.GeoMultiPoint;
575  case GeoLineString:
576  return ExtensionFunction.ExtArgumentType.GeoLineString;
577  case GeoMultiLineString:
578  return ExtensionFunction.ExtArgumentType.GeoMultiLineString;
579  case Cursor:
580  return ExtensionFunction.ExtArgumentType.Cursor;
581  case GeoPolygon:
582  return ExtensionFunction.ExtArgumentType.GeoPolygon;
583  case GeoMultiPolygon:
584  return ExtensionFunction.ExtArgumentType.GeoMultiPolygon;
585  case TextEncodingNone:
586  return ExtensionFunction.ExtArgumentType.TextEncodingNone;
587  case TextEncodingDict:
588  return ExtensionFunction.ExtArgumentType.TextEncodingDict;
589  case Timestamp:
590  return ExtensionFunction.ExtArgumentType.Timestamp;
591  case ColumnListInt8:
592  return ExtensionFunction.ExtArgumentType.ColumnListInt8;
593  case ColumnListInt16:
594  return ExtensionFunction.ExtArgumentType.ColumnListInt16;
595  case ColumnListInt32:
596  return ExtensionFunction.ExtArgumentType.ColumnListInt32;
597  case ColumnListInt64:
598  return ExtensionFunction.ExtArgumentType.ColumnListInt64;
599  case ColumnListFloat:
600  return ExtensionFunction.ExtArgumentType.ColumnListFloat;
601  case ColumnListDouble:
602  return ExtensionFunction.ExtArgumentType.ColumnListDouble;
603  case ColumnListBool:
604  return ExtensionFunction.ExtArgumentType.ColumnListBool;
606  return ExtensionFunction.ExtArgumentType.ColumnListTextEncodingDict;
607  case ColumnArrayInt8:
608  return ExtensionFunction.ExtArgumentType.ColumnArrayInt8;
609  case ColumnArrayInt16:
610  return ExtensionFunction.ExtArgumentType.ColumnArrayInt16;
611  case ColumnArrayInt32:
612  return ExtensionFunction.ExtArgumentType.ColumnArrayInt32;
613  case ColumnArrayInt64:
614  return ExtensionFunction.ExtArgumentType.ColumnArrayInt64;
615  case ColumnArrayFloat:
616  return ExtensionFunction.ExtArgumentType.ColumnArrayFloat;
617  case ColumnArrayDouble:
618  return ExtensionFunction.ExtArgumentType.ColumnArrayDouble;
619  case ColumnArrayBool:
620  return ExtensionFunction.ExtArgumentType.ColumnArrayBool;
622  return ExtensionFunction.ExtArgumentType.ColumnArrayTextEncodingDict;
623  case ColumnListArrayInt8:
624  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt8;
626  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt16;
628  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt32;
630  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt64;
632  return ExtensionFunction.ExtArgumentType.ColumnListArrayFloat;
634  return ExtensionFunction.ExtArgumentType.ColumnListArrayDouble;
635  case ColumnListArrayBool:
636  return ExtensionFunction.ExtArgumentType.ColumnListArrayBool;
638  return ExtensionFunction.ExtArgumentType.ColumnListArrayTextEncodingDict;
639  default:
640  HEAVYDBLOGGER.error("toExtArgumentType: unknown type " + type);
641  return null;
642  }
643  }
644 
645  private static TCompletionHintType hintTypeToThrift(final SqlMonikerType type) {
646  switch (type) {
647  case COLUMN:
648  return TCompletionHintType.COLUMN;
649  case TABLE:
650  return TCompletionHintType.TABLE;
651  case VIEW:
652  return TCompletionHintType.VIEW;
653  case SCHEMA:
654  return TCompletionHintType.SCHEMA;
655  case CATALOG:
656  return TCompletionHintType.CATALOG;
657  case REPOSITORY:
658  return TCompletionHintType.REPOSITORY;
659  case FUNCTION:
660  return TCompletionHintType.FUNCTION;
661  case KEYWORD:
662  return TCompletionHintType.KEYWORD;
663  default:
664  return null;
665  }
666  }
667 }
Simplified core of GeoJSON Polygon coordinates definition.
Definition: heavydbTypes.h:502
CalciteServerHandler(int dbPort, String dataDir, String extensionFunctionsAstFile, SockTransportProperties skT, String udfAstFile)
std::string toString(const QueryDescriptionType &type)
Definition: Types.h:64
void setRuntimeExtensionFunctions(List< TUserDefinedFunction > udfs, List< TUserDefinedTableFunction > udtfs, boolean isruntime)
Simplified core of GeoJSON MultiPolygon coordinates definition.
Definition: heavydbTypes.h:523
static ExtensionFunction.ExtArgumentType toExtArgumentType(TExtArgumentType type)
void updateMetadata(String catalog, String table)
Map< String, ExtensionFunction > udfRTSigs
static TCompletionHintType hintTypeToThrift(final SqlMonikerType type)
static ExtensionFunction toExtensionFunction(TUserDefinedFunction udf, boolean isruntime)
static ExtensionFunction toExtensionFunction(TUserDefinedTableFunction udtf, boolean isruntime)
string name
Definition: setup.in.py:72
TPlanResult process(String user, String session, String catalog, String queryText, TQueryParsingOption queryParsingOption, TOptimizationOption optimizationOption, List< TRestriction > trestrictions)
List< TCompletionHint > getCompletionHints(String user, String session, String catalog, List< String > visible_tables, String sql, int cursor)