OmniSciDB  c1a53651b2
 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  // TODO: Add update type parameter to API.
309  @Override
310  public void updateMetadata(String catalog, String table) throws TException {
311  HEAVYDBLOGGER.debug(
312  "Received invalidation from server for " + catalog + " : " + table);
313  long timer = System.currentTimeMillis();
314  callCount++;
316  try {
317  parser = (HeavyDBParser) parserPool.borrowObject();
318  } catch (Exception ex) {
319  String msg = "Could not get Parse Item from pool: " + ex.getMessage();
320  HEAVYDBLOGGER.error(msg, ex);
321  return;
322  }
323  CURRENT_PARSER.set(parser);
324  try {
325  parser.updateMetaData(catalog, table);
326  } finally {
327  CURRENT_PARSER.set(null);
328  try {
329  // put parser object back in pool for others to use
330  HEAVYDBLOGGER.debug("Returning object to pool");
331  parserPool.returnObject(parser);
332  } catch (Exception ex) {
333  String msg = "Could not return parse object: " + ex.getMessage();
334  HEAVYDBLOGGER.error(msg, ex);
335  }
336  }
337  }
338 
339  @Override
340  public List<TCompletionHint> getCompletionHints(String user,
341  String session,
342  String catalog,
343  List<String> visible_tables,
344  String sql,
345  int cursor) throws TException {
346  callCount++;
348  try {
349  parser = (HeavyDBParser) parserPool.borrowObject();
350  } catch (Exception ex) {
351  String msg = "Could not get Parse Item from pool: " + ex.getMessage();
352  HEAVYDBLOGGER.error(msg, ex);
353  throw new TException(msg);
354  }
355  HeavyDBUser dbUser = new HeavyDBUser(user, session, catalog, dbPort, null);
356  HEAVYDBLOGGER.debug("getCompletionHints was called User: " + user
357  + " Catalog: " + catalog + " sql: " + sql);
358  parser.setUser(dbUser);
359  CURRENT_PARSER.set(parser);
360 
361  HeavyDBPlanner.CompletionResult completion_result;
362  try {
363  completion_result = parser.getCompletionHints(sql, cursor, visible_tables);
364  } catch (Exception ex) {
365  String msg = "Could not retrieve completion hints: " + ex.getMessage();
366  HEAVYDBLOGGER.error(msg, ex);
367  return new ArrayList<>();
368  } finally {
369  CURRENT_PARSER.set(null);
370  try {
371  // put parser object back in pool for others to use
372  parserPool.returnObject(parser);
373  } catch (Exception ex) {
374  String msg = "Could not return parse object: " + ex.getMessage();
375  HEAVYDBLOGGER.error(msg, ex);
376  throw new InvalidParseRequest(-4, msg);
377  }
378  }
379  List<TCompletionHint> result = new ArrayList<>();
380  for (final SqlMoniker hint : completion_result.hints) {
381  result.add(new TCompletionHint(hintTypeToThrift(hint.getType()),
382  hint.getFullyQualifiedNames(),
383  completion_result.replaced));
384  }
385  return result;
386  }
387 
388  @Override
389  public void setRuntimeExtensionFunctions(List<TUserDefinedFunction> udfs,
390  List<TUserDefinedTableFunction> udtfs,
391  boolean isruntime) {
392  if (isruntime) {
393  // Clean up previously defined Runtime UDFs
394  if (udfRTSigs != null) {
395  for (String name : udfRTSigs.keySet()) extSigs.remove(name);
396  udfRTSigsJson = "";
397  udfRTSigs.clear();
398  } else {
399  udfRTSigs = new HashMap<String, ExtensionFunction>();
400  }
401 
402  for (TUserDefinedFunction udf : udfs) {
403  udfRTSigs.put(udf.name, toExtensionFunction(udf, isruntime));
404  }
405 
406  for (TUserDefinedTableFunction udtf : udtfs) {
407  udfRTSigs.put(udtf.name, toExtensionFunction(udtf, isruntime));
408  }
409 
410  // Avoid overwritting compiled and Loadtime UDFs:
411  for (String name : udfRTSigs.keySet()) {
412  if (extSigs.containsKey(name)) {
413  HEAVYDBLOGGER.error("Extension function `" + name
414  + "` exists. Skipping runtime extenension function with the same name.");
415  udfRTSigs.remove(name);
416  }
417  }
418  // udfRTSigsJson will contain only the signatures of UDFs:
419  udfRTSigsJson = ExtensionFunctionSignatureParser.signaturesToJson(udfRTSigs);
420  // Expose RT UDFs to Calcite server:
421  extSigs.putAll(udfRTSigs);
422  } else {
423  // currently only LoadTime UDTFs can be registered via calcite thrift interface
424  if (udtfSigs == null) {
425  udtfSigs = new HashMap<String, ExtensionFunction>();
426  }
427 
428  for (TUserDefinedTableFunction udtf : udtfs) {
429  udtfSigs.put(udtf.name, toExtensionFunction(udtf, isruntime));
430  }
431 
432  extSigs.putAll(udtfSigs);
433  }
434 
435  calciteParserFactory.updateOperatorTable();
436  }
437 
439  TUserDefinedFunction udf, boolean isruntime) {
440  List<ExtensionFunction.ExtArgumentType> args =
441  new ArrayList<ExtensionFunction.ExtArgumentType>();
442  for (TExtArgumentType atype : udf.argTypes) {
443  final ExtensionFunction.ExtArgumentType arg_type = toExtArgumentType(atype);
444  if (arg_type != ExtensionFunction.ExtArgumentType.Void) {
445  args.add(arg_type);
446  }
447  }
448  return new ExtensionFunction(args, toExtArgumentType(udf.retType), udf.annotations);
449  }
450 
452  TUserDefinedTableFunction udtf, boolean isruntime) {
453  int sqlInputArgIdx = 0;
454  int inputArgIdx = 0;
455  int outputArgIdx = 0;
456  List<String> names = new ArrayList<String>();
457  List<ExtensionFunction.ExtArgumentType> args = new ArrayList<>();
458  Map<String, List<ExtensionFunction.ExtArgumentType>> cursor_field_types =
459  new HashMap<>();
460  for (TExtArgumentType atype : udtf.sqlArgTypes) {
461  args.add(toExtArgumentType(atype));
462  Map<String, String> annot = udtf.annotations.get(sqlInputArgIdx);
463  String name = annot.getOrDefault("name", "inp" + sqlInputArgIdx);
464  if (atype == TExtArgumentType.Cursor) {
465  String field_names_annot = annot.getOrDefault("fields", "");
466  List<ExtensionFunction.ExtArgumentType> field_types = new ArrayList<>();
467  if (field_names_annot.length() > 0) {
468  String[] field_names =
469  field_names_annot.substring(1, field_names_annot.length() - 1)
470  .split(",");
471  for (int i = 0; i < field_names.length; i++) {
472  field_types.add(
473  toExtArgumentType(udtf.getInputArgTypes().get(inputArgIdx++)));
474  }
475  } else {
476  if (!isruntime) {
477  field_types.add(
478  toExtArgumentType(udtf.getInputArgTypes().get(inputArgIdx++)));
479  }
480  }
481  name = name + field_names_annot;
482  cursor_field_types.put(name, field_types);
483  } else {
484  inputArgIdx++;
485  }
486  names.add(name);
487  sqlInputArgIdx++;
488  }
489 
490  List<ExtensionFunction.ExtArgumentType> outs = new ArrayList<>();
491  for (TExtArgumentType otype : udtf.outputArgTypes) {
492  outs.add(toExtArgumentType(otype));
493  Map<String, String> annot = udtf.annotations.get(sqlInputArgIdx);
494  names.add(annot.getOrDefault("name", "out" + outputArgIdx));
495  sqlInputArgIdx++;
496  outputArgIdx++;
497  }
498  return new ExtensionFunction(args,
499  outs,
500  names,
501  udtf.annotations.get(udtf.annotations.size() - 1),
502  cursor_field_types);
503  }
504 
505  private static ExtensionFunction.ExtArgumentType toExtArgumentType(
506  TExtArgumentType type) {
507  switch (type) {
508  case Int8:
509  return ExtensionFunction.ExtArgumentType.Int8;
510  case Int16:
511  return ExtensionFunction.ExtArgumentType.Int16;
512  case Int32:
513  return ExtensionFunction.ExtArgumentType.Int32;
514  case Int64:
515  return ExtensionFunction.ExtArgumentType.Int64;
516  case Float:
517  return ExtensionFunction.ExtArgumentType.Float;
518  case Double:
520  case Void:
521  return ExtensionFunction.ExtArgumentType.Void;
522  case PInt8:
523  return ExtensionFunction.ExtArgumentType.PInt8;
524  case PInt16:
525  return ExtensionFunction.ExtArgumentType.PInt16;
526  case PInt32:
527  return ExtensionFunction.ExtArgumentType.PInt32;
528  case PInt64:
529  return ExtensionFunction.ExtArgumentType.PInt64;
530  case PFloat:
531  return ExtensionFunction.ExtArgumentType.PFloat;
532  case PDouble:
533  return ExtensionFunction.ExtArgumentType.PDouble;
534  case PBool:
535  return ExtensionFunction.ExtArgumentType.PBool;
536  case Bool:
537  return ExtensionFunction.ExtArgumentType.Bool;
538  case ArrayInt8:
539  return ExtensionFunction.ExtArgumentType.ArrayInt8;
540  case ArrayInt16:
541  return ExtensionFunction.ExtArgumentType.ArrayInt16;
542  case ArrayInt32:
543  return ExtensionFunction.ExtArgumentType.ArrayInt32;
544  case ArrayInt64:
545  return ExtensionFunction.ExtArgumentType.ArrayInt64;
546  case ArrayFloat:
547  return ExtensionFunction.ExtArgumentType.ArrayFloat;
548  case ArrayDouble:
549  return ExtensionFunction.ExtArgumentType.ArrayDouble;
550  case ArrayBool:
551  return ExtensionFunction.ExtArgumentType.ArrayBool;
553  return ExtensionFunction.ExtArgumentType.ArrayTextEncodingDict;
554  case ColumnInt8:
555  return ExtensionFunction.ExtArgumentType.ColumnInt8;
556  case ColumnInt16:
557  return ExtensionFunction.ExtArgumentType.ColumnInt16;
558  case ColumnInt32:
559  return ExtensionFunction.ExtArgumentType.ColumnInt32;
560  case ColumnInt64:
561  return ExtensionFunction.ExtArgumentType.ColumnInt64;
562  case ColumnFloat:
563  return ExtensionFunction.ExtArgumentType.ColumnFloat;
564  case ColumnDouble:
565  return ExtensionFunction.ExtArgumentType.ColumnDouble;
566  case ColumnBool:
567  return ExtensionFunction.ExtArgumentType.ColumnBool;
569  return ExtensionFunction.ExtArgumentType.ColumnTextEncodingDict;
570  case ColumnTimestamp:
571  return ExtensionFunction.ExtArgumentType.ColumnTimestamp;
572  case GeoPoint:
573  return ExtensionFunction.ExtArgumentType.GeoPoint;
574  case GeoMultiPoint:
575  return ExtensionFunction.ExtArgumentType.GeoMultiPoint;
576  case GeoLineString:
577  return ExtensionFunction.ExtArgumentType.GeoLineString;
578  case GeoMultiLineString:
579  return ExtensionFunction.ExtArgumentType.GeoMultiLineString;
580  case Cursor:
581  return ExtensionFunction.ExtArgumentType.Cursor;
582  case GeoPolygon:
583  return ExtensionFunction.ExtArgumentType.GeoPolygon;
584  case GeoMultiPolygon:
585  return ExtensionFunction.ExtArgumentType.GeoMultiPolygon;
586  case TextEncodingNone:
587  return ExtensionFunction.ExtArgumentType.TextEncodingNone;
588  case TextEncodingDict:
589  return ExtensionFunction.ExtArgumentType.TextEncodingDict;
590  case Timestamp:
591  return ExtensionFunction.ExtArgumentType.Timestamp;
592  case ColumnListInt8:
593  return ExtensionFunction.ExtArgumentType.ColumnListInt8;
594  case ColumnListInt16:
595  return ExtensionFunction.ExtArgumentType.ColumnListInt16;
596  case ColumnListInt32:
597  return ExtensionFunction.ExtArgumentType.ColumnListInt32;
598  case ColumnListInt64:
599  return ExtensionFunction.ExtArgumentType.ColumnListInt64;
600  case ColumnListFloat:
601  return ExtensionFunction.ExtArgumentType.ColumnListFloat;
602  case ColumnListDouble:
603  return ExtensionFunction.ExtArgumentType.ColumnListDouble;
604  case ColumnListBool:
605  return ExtensionFunction.ExtArgumentType.ColumnListBool;
607  return ExtensionFunction.ExtArgumentType.ColumnListTextEncodingDict;
608  case ColumnArrayInt8:
609  return ExtensionFunction.ExtArgumentType.ColumnArrayInt8;
610  case ColumnArrayInt16:
611  return ExtensionFunction.ExtArgumentType.ColumnArrayInt16;
612  case ColumnArrayInt32:
613  return ExtensionFunction.ExtArgumentType.ColumnArrayInt32;
614  case ColumnArrayInt64:
615  return ExtensionFunction.ExtArgumentType.ColumnArrayInt64;
616  case ColumnArrayFloat:
617  return ExtensionFunction.ExtArgumentType.ColumnArrayFloat;
618  case ColumnArrayDouble:
619  return ExtensionFunction.ExtArgumentType.ColumnArrayDouble;
620  case ColumnArrayBool:
621  return ExtensionFunction.ExtArgumentType.ColumnArrayBool;
623  return ExtensionFunction.ExtArgumentType.ColumnArrayTextEncodingDict;
624  case ColumnListArrayInt8:
625  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt8;
627  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt16;
629  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt32;
631  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt64;
633  return ExtensionFunction.ExtArgumentType.ColumnListArrayFloat;
635  return ExtensionFunction.ExtArgumentType.ColumnListArrayDouble;
636  case ColumnListArrayBool:
637  return ExtensionFunction.ExtArgumentType.ColumnListArrayBool;
639  return ExtensionFunction.ExtArgumentType.ColumnListArrayTextEncodingDict;
640  case DayTimeInterval:
641  return ExtensionFunction.ExtArgumentType.DayTimeInterval;
643  return ExtensionFunction.ExtArgumentType.YearMonthTimeInterval;
644  default:
645  HEAVYDBLOGGER.error("toExtArgumentType: unknown type " + type);
646  return null;
647  }
648  }
649 
650  private static TCompletionHintType hintTypeToThrift(final SqlMonikerType type) {
651  switch (type) {
652  case COLUMN:
653  return TCompletionHintType.COLUMN;
654  case TABLE:
655  return TCompletionHintType.TABLE;
656  case VIEW:
657  return TCompletionHintType.VIEW;
658  case SCHEMA:
659  return TCompletionHintType.SCHEMA;
660  case CATALOG:
661  return TCompletionHintType.CATALOG;
662  case REPOSITORY:
663  return TCompletionHintType.REPOSITORY;
664  case FUNCTION:
665  return TCompletionHintType.FUNCTION;
666  case KEYWORD:
667  return TCompletionHintType.KEYWORD;
668  default:
669  return null;
670  }
671  }
672 }
Simplified core of GeoJSON Polygon coordinates definition.
Definition: heavydbTypes.h:661
CalciteServerHandler(int dbPort, String dataDir, String extensionFunctionsAstFile, SockTransportProperties skT, String udfAstFile)
void setRuntimeExtensionFunctions(List< TUserDefinedFunction > udfs, List< TUserDefinedTableFunction > udtfs, boolean isruntime)
Simplified core of GeoJSON MultiPolygon coordinates definition.
Definition: heavydbTypes.h:682
static ExtensionFunction.ExtArgumentType toExtArgumentType(TExtArgumentType type)
void updateMetadata(String catalog, String table)
std::string toString(const ExecutorDeviceType &device_type)
Map< String, ExtensionFunction > udfRTSigs
static TCompletionHintType hintTypeToThrift(final SqlMonikerType type)
final List< Map< String, String > > annotations
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)