OmniSciDB  4201147b46
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HeavyAIDatabaseMetaData.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 package ai.heavy.jdbc;
17 
18 import org.apache.thrift.TException;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21 
22 import java.sql.Connection;
23 import java.sql.DatabaseMetaData;
24 import java.sql.ResultSet;
25 import java.sql.RowIdLifetime;
26 import java.sql.SQLException;
27 import java.util.*;
28 
29 import ai.heavy.thrift.server.TColumn;
30 import ai.heavy.thrift.server.TColumnData;
31 import ai.heavy.thrift.server.TColumnType;
32 import ai.heavy.thrift.server.TDBInfo;
33 import ai.heavy.thrift.server.TDBObject;
34 import ai.heavy.thrift.server.TDBObjectType;
35 import ai.heavy.thrift.server.TDatumType;
36 import ai.heavy.thrift.server.TEncodingType;
37 import ai.heavy.thrift.server.TQueryResult;
38 import ai.heavy.thrift.server.TRowSet;
39 import ai.heavy.thrift.server.TTableDetails;
40 import ai.heavy.thrift.server.TTablePermissions;
41 import ai.heavy.thrift.server.TTypeInfo;
42 
43 class HeavyAIDatabaseMetaData implements DatabaseMetaData {
44  final static Logger HEAVYDBLOGGER =
45  LoggerFactory.getLogger(HeavyAIDatabaseMetaData.class);
46 
50  String databaseVersion = null;
51 
52  public HeavyAIDatabaseMetaData(HeavyAIConnection connection) throws SQLException {
53  this.con = connection;
54 
55  try {
56  databaseVersion = con.client.get_version();
57  } catch (TException ex) {
58  throw new SQLException("Failed to get DB version " + ex.toString());
59  }
60  String vers[] = databaseVersion.split("\\.");
61  try {
62  databaseMajorVersion = Integer.parseInt(vers[0]);
63  databaseMinorVersion = Integer.parseInt(vers[1]);
64  } catch (NumberFormatException ex) {
65  throw new SQLException(
66  "Non-numeric version returned from HEAVY.AI server: " + ex.getMessage());
67  }
68  }
69 
70  @Override
71  public boolean allProceduresAreCallable() throws SQLException {
72  HEAVYDBLOGGER.debug("Entered");
73  return false;
74  }
75 
76  @Override
77  public boolean allTablesAreSelectable() throws SQLException {
78  HEAVYDBLOGGER.debug("Entered");
79  return true;
80  }
81 
82  @Override
83  public String getURL() throws SQLException {
84  HEAVYDBLOGGER.debug("Entered");
85  return con.url;
86  }
87 
88  @Override
89  public String getUserName() throws SQLException {
90  HEAVYDBLOGGER.debug("Entered");
91  return (String) con.cP.get(Options.user);
92  }
93 
94  @Override
95  public boolean isReadOnly() throws SQLException {
96  HEAVYDBLOGGER.debug("Entered");
97  return true;
98  }
99 
100  @Override
101  public boolean nullsAreSortedHigh() throws SQLException {
102  HEAVYDBLOGGER.debug("Entered");
103  return true;
104  }
105 
106  @Override
107  public boolean nullsAreSortedLow() throws SQLException {
108  HEAVYDBLOGGER.debug("Entered");
109  return false;
110  }
111 
112  @Override
113  public boolean nullsAreSortedAtStart() throws SQLException {
114  HEAVYDBLOGGER.debug("Entered");
115  return false;
116  }
117 
118  @Override
119  public boolean nullsAreSortedAtEnd() throws SQLException {
120  HEAVYDBLOGGER.debug("Entered");
121  return true;
122  }
123 
124  @Override
125  public String getDatabaseProductName() throws SQLException {
126  HEAVYDBLOGGER.debug("Entered");
127  return "OmniSciDB";
128  }
129 
130  @Override
132  throws SQLException { // logger.debug("Entered");
133  HEAVYDBLOGGER.debug("Entered");
134  return this.databaseVersion;
135  }
136 
137  @Override
138  public String getDriverName() throws SQLException {
139  HEAVYDBLOGGER.debug("Entered");
140  return "OmniSciDB JDBC Driver";
141  }
142 
143  @Override
144  public String getDriverVersion() throws SQLException { // logger.debug("Entered");
145  HEAVYDBLOGGER.debug("Entered");
147  }
148 
149  @Override
150  public int getDriverMajorVersion() {
152  }
153 
154  @Override
155  public int getDriverMinorVersion() {
157  }
158 
159  @Override
160  public boolean usesLocalFiles() throws SQLException {
161  HEAVYDBLOGGER.debug("Entered");
162  return false;
163  }
164 
165  @Override
166  public boolean usesLocalFilePerTable() throws SQLException {
167  HEAVYDBLOGGER.debug("Entered");
168  return false;
169  }
170 
171  @Override
172  public boolean supportsMixedCaseIdentifiers() throws SQLException {
173  HEAVYDBLOGGER.debug("Entered");
174  return true;
175  }
176 
177  @Override
178  public boolean storesUpperCaseIdentifiers() throws SQLException {
179  HEAVYDBLOGGER.debug("Entered");
180  return false;
181  }
182 
183  @Override
184  public boolean storesLowerCaseIdentifiers() throws SQLException {
185  HEAVYDBLOGGER.debug("Entered");
186  return false;
187  }
188 
189  @Override
190  public boolean storesMixedCaseIdentifiers() throws SQLException {
191  HEAVYDBLOGGER.debug("Entered");
192  return true;
193  }
194 
195  @Override
196  public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
197  HEAVYDBLOGGER.debug("Entered");
198  return true;
199  }
200 
201  @Override
202  public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
203  HEAVYDBLOGGER.debug("Entered");
204  return false;
205  }
206 
207  @Override
208  public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
209  HEAVYDBLOGGER.debug("Entered");
210  return false;
211  }
212 
213  @Override
214  public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
215  HEAVYDBLOGGER.debug("Entered");
216  return false;
217  }
218 
219  @Override
220  public String getIdentifierQuoteString() throws SQLException {
221  HEAVYDBLOGGER.debug("Entered");
222  return " ";
223  }
224 
225  @Override
226  public String getSQLKeywords() throws SQLException {
227  HEAVYDBLOGGER.debug("Entered");
228  return "";
229  }
230 
231  @Override
232  public String getNumericFunctions() throws SQLException {
233  HEAVYDBLOGGER.debug("Entered");
234  return "ACOS(float), ACOS(number), ASIN, ATAN2, CEIL, COS, COT, DEGREES, EXP, FLOOR, LN, LOG, PI(), POWER, SQRT"
235  + ", RADIANS, ROUND, SIN, TAN, ATAN, ABS, MOD SIGN, TRUNCATE";
236  }
237 
238  @Override
239  public String getStringFunctions() throws SQLException {
240  HEAVYDBLOGGER.debug("Entered");
241  return "CHAR_LENGTH, CHAR, KEY_FOR_STRING";
242  }
243 
244  @Override
245  public String getSystemFunctions() throws SQLException {
246  HEAVYDBLOGGER.debug("Entered");
247  return "";
248  }
249 
250  @Override
251  public String getTimeDateFunctions() throws SQLException {
252  HEAVYDBLOGGER.debug("Entered");
253  // return "NOW,CURDATE,SECOND,HOUR,YEAR,EXTRACT,QUARTER,WEEK,MONTH,DATETRUNC";
254  return "DATE_TRUNC, NOW, EXTRACT";
255  }
256 
257  @Override
258  public String getSearchStringEscape() throws SQLException {
259  HEAVYDBLOGGER.debug("Entered");
260  return "\\";
261  }
262 
263  @Override
264  public String getExtraNameCharacters() throws SQLException {
265  HEAVYDBLOGGER.debug("Entered");
266  return "";
267  }
268 
269  @Override
270  public boolean supportsAlterTableWithAddColumn() throws SQLException {
271  HEAVYDBLOGGER.debug("Entered");
272  return true;
273  }
274 
275  @Override
276  public boolean supportsAlterTableWithDropColumn() throws SQLException {
277  HEAVYDBLOGGER.debug("Entered");
278  return true;
279  }
280 
281  @Override
282  public boolean supportsColumnAliasing() throws SQLException {
283  HEAVYDBLOGGER.debug("Entered");
284  return true;
285  }
286 
287  @Override
288  public boolean nullPlusNonNullIsNull() throws SQLException {
289  HEAVYDBLOGGER.debug("Entered");
290  return true;
291  }
292 
293  @Override
294  public boolean supportsConvert() throws SQLException {
295  HEAVYDBLOGGER.debug("Entered");
296  return false;
297  }
298 
299  @Override
300  public boolean supportsConvert(int fromType, int toType) throws SQLException {
301  HEAVYDBLOGGER.debug("Entered");
302  return false;
303  }
304 
305  @Override
306  public boolean supportsTableCorrelationNames() throws SQLException {
307  HEAVYDBLOGGER.debug("Entered");
308  return true;
309  }
310 
311  @Override
312  public boolean supportsDifferentTableCorrelationNames() throws SQLException {
313  HEAVYDBLOGGER.debug("Entered");
314  return true;
315  }
316 
317  @Override
318  public boolean supportsExpressionsInOrderBy() throws SQLException {
319  HEAVYDBLOGGER.debug("Entered");
320  return true;
321  }
322 
323  @Override
324  public boolean supportsOrderByUnrelated() throws SQLException {
325  HEAVYDBLOGGER.debug("Entered");
326  return true;
327  }
328 
329  @Override
330  public boolean supportsGroupBy() throws SQLException {
331  HEAVYDBLOGGER.debug("Entered");
332  return true;
333  }
334 
335  @Override
336  public boolean supportsGroupByUnrelated() throws SQLException {
337  HEAVYDBLOGGER.debug("Entered");
338  return true;
339  }
340 
341  @Override
342  public boolean supportsGroupByBeyondSelect() throws SQLException {
343  HEAVYDBLOGGER.debug("Entered");
344  return true;
345  }
346 
347  @Override
348  public boolean supportsLikeEscapeClause() throws SQLException {
349  HEAVYDBLOGGER.debug("Entered");
350  return false;
351  }
352 
353  @Override
354  public boolean supportsMultipleResultSets() throws SQLException {
355  HEAVYDBLOGGER.debug("Entered");
356  return false;
357  }
358 
359  @Override
360  public boolean supportsMultipleTransactions() throws SQLException {
361  HEAVYDBLOGGER.debug("Entered");
362  return false;
363  }
364 
365  @Override
366  public boolean supportsNonNullableColumns() throws SQLException {
367  HEAVYDBLOGGER.debug("Entered");
368  return true;
369  }
370 
371  @Override
372  public boolean supportsMinimumSQLGrammar() throws SQLException {
373  HEAVYDBLOGGER.debug("Entered");
374  return true;
375  }
376 
377  @Override
378  public boolean supportsCoreSQLGrammar() throws SQLException {
379  HEAVYDBLOGGER.debug("Entered");
380  return true;
381  }
382 
383  @Override
384  public boolean supportsExtendedSQLGrammar() throws SQLException {
385  HEAVYDBLOGGER.debug("Entered");
386  return true;
387  }
388 
389  @Override
390  public boolean supportsANSI92EntryLevelSQL() throws SQLException {
391  HEAVYDBLOGGER.debug("Entered");
392  return true;
393  }
394 
395  @Override
396  public boolean supportsANSI92IntermediateSQL() throws SQLException {
397  HEAVYDBLOGGER.debug("Entered");
398  return false;
399  }
400 
401  @Override
402  public boolean supportsANSI92FullSQL() throws SQLException {
403  HEAVYDBLOGGER.debug("Entered");
404  return false;
405  }
406 
407  @Override
408  public boolean supportsIntegrityEnhancementFacility() throws SQLException {
409  HEAVYDBLOGGER.debug("Entered");
410  return false;
411  }
412 
413  @Override
414  public boolean supportsOuterJoins() throws SQLException {
415  HEAVYDBLOGGER.debug("Entered");
416  return false;
417  }
418 
419  @Override
420  public boolean supportsFullOuterJoins() throws SQLException {
421  HEAVYDBLOGGER.debug("Entered");
422  return false;
423  }
424 
425  @Override
426  public boolean supportsLimitedOuterJoins() throws SQLException {
427  HEAVYDBLOGGER.debug("Entered");
428  return true;
429  }
430 
431  @Override
432  public String getSchemaTerm() throws SQLException {
433  HEAVYDBLOGGER.debug("Entered");
434  return "Database";
435  }
436 
437  @Override
438  public String getProcedureTerm() throws SQLException {
439  HEAVYDBLOGGER.debug("Entered");
440  return "N/A";
441  }
442 
443  @Override
444  public String getCatalogTerm() throws SQLException {
445  HEAVYDBLOGGER.debug("Entered");
446  return "N/A";
447  }
448 
449  @Override
450  public boolean isCatalogAtStart() throws SQLException {
451  HEAVYDBLOGGER.debug("Entered");
452  return true;
453  }
454 
455  @Override
456  public String getCatalogSeparator() throws SQLException {
457  HEAVYDBLOGGER.debug("Entered");
458  return ".";
459  }
460 
461  @Override
462  public boolean supportsSchemasInDataManipulation() throws SQLException {
463  HEAVYDBLOGGER.debug("Entered");
464  return false;
465  }
466 
467  @Override
468  public boolean supportsSchemasInProcedureCalls() throws SQLException {
469  HEAVYDBLOGGER.debug("Entered");
470  return false;
471  }
472 
473  @Override
474  public boolean supportsSchemasInTableDefinitions() throws SQLException {
475  HEAVYDBLOGGER.debug("Entered");
476  return false;
477  }
478 
479  @Override
480  public boolean supportsSchemasInIndexDefinitions() throws SQLException {
481  HEAVYDBLOGGER.debug("Entered");
482  return false;
483  }
484 
485  @Override
486  public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
487  HEAVYDBLOGGER.debug("Entered");
488  return false;
489  }
490 
491  @Override
492  public boolean supportsCatalogsInDataManipulation() throws SQLException {
493  HEAVYDBLOGGER.debug("Entered");
494  return false;
495  }
496 
497  @Override
498  public boolean supportsCatalogsInProcedureCalls() throws SQLException {
499  HEAVYDBLOGGER.debug("Entered");
500  return false;
501  }
502 
503  @Override
504  public boolean supportsCatalogsInTableDefinitions() throws SQLException {
505  HEAVYDBLOGGER.debug("Entered");
506  return false;
507  }
508 
509  @Override
510  public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
511  HEAVYDBLOGGER.debug("Entered");
512  return false;
513  }
514 
515  @Override
516  public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
517  HEAVYDBLOGGER.debug("Entered");
518  return false;
519  }
520 
521  @Override
522  public boolean supportsPositionedDelete() throws SQLException {
523  HEAVYDBLOGGER.debug("Entered");
524  return false;
525  }
526 
527  @Override
528  public boolean supportsPositionedUpdate() throws SQLException {
529  HEAVYDBLOGGER.debug("Entered");
530  return false;
531  }
532 
533  @Override
534  public boolean supportsSelectForUpdate() throws SQLException {
535  HEAVYDBLOGGER.debug("Entered");
536  return false;
537  }
538 
539  @Override
540  public boolean supportsStoredProcedures() throws SQLException {
541  HEAVYDBLOGGER.debug("Entered");
542  return false;
543  }
544 
545  @Override
546  public boolean supportsSubqueriesInComparisons() throws SQLException {
547  HEAVYDBLOGGER.debug("Entered");
548  return true;
549  }
550 
551  @Override
552  public boolean supportsSubqueriesInExists() throws SQLException {
553  HEAVYDBLOGGER.debug("Entered");
554  return true;
555  }
556 
557  @Override
558  public boolean supportsSubqueriesInIns() throws SQLException {
559  HEAVYDBLOGGER.debug("Entered");
560  return true;
561  }
562 
563  @Override
564  public boolean supportsSubqueriesInQuantifieds() throws SQLException {
565  HEAVYDBLOGGER.debug("Entered");
566  return true;
567  }
568 
569  @Override
570  public boolean supportsCorrelatedSubqueries() throws SQLException {
571  HEAVYDBLOGGER.debug("Entered");
572  return false;
573  }
574 
575  @Override
576  public boolean supportsUnion() throws SQLException {
577  HEAVYDBLOGGER.debug("Entered");
578  return false;
579  }
580 
581  @Override
582  public boolean supportsUnionAll() throws SQLException {
583  HEAVYDBLOGGER.debug("Entered");
584  return false;
585  }
586 
587  @Override
588  public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
589  HEAVYDBLOGGER.debug("Entered");
590  return false;
591  }
592 
593  @Override
594  public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
595  HEAVYDBLOGGER.debug("Entered");
596  return false;
597  }
598 
599  @Override
600  public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
601  HEAVYDBLOGGER.debug("Entered");
602  return false;
603  }
604 
605  @Override
606  public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
607  HEAVYDBLOGGER.debug("Entered");
608  return false;
609  }
610 
611  @Override
612  public int getMaxBinaryLiteralLength() throws SQLException {
613  HEAVYDBLOGGER.debug("Entered");
614  return 0;
615  }
616 
617  @Override
618  public int getMaxCharLiteralLength() throws SQLException {
619  HEAVYDBLOGGER.debug("Entered");
620  return 0;
621  }
622 
623  @Override
624  public int getMaxColumnNameLength() throws SQLException {
625  HEAVYDBLOGGER.debug("Entered");
626  return 0;
627  }
628 
629  @Override
630  public int getMaxColumnsInGroupBy() throws SQLException {
631  HEAVYDBLOGGER.debug("Entered");
632  return 0;
633  }
634 
635  @Override
636  public int getMaxColumnsInIndex() throws SQLException {
637  HEAVYDBLOGGER.debug("Entered");
638  return 0;
639  }
640 
641  @Override
642  public int getMaxColumnsInOrderBy() throws SQLException {
643  HEAVYDBLOGGER.debug("Entered");
644  return 0;
645  }
646 
647  @Override
648  public int getMaxColumnsInSelect() throws SQLException {
649  HEAVYDBLOGGER.debug("Entered");
650  return 0;
651  }
652 
653  @Override
654  public int getMaxColumnsInTable() throws SQLException {
655  HEAVYDBLOGGER.debug("Entered");
656  return 0;
657  }
658 
659  @Override
660  public int getMaxConnections() throws SQLException {
661  HEAVYDBLOGGER.debug("Entered");
662  return 0;
663  }
664 
665  @Override
666  public int getMaxCursorNameLength() throws SQLException {
667  HEAVYDBLOGGER.debug("Entered");
668  return 0;
669  }
670 
671  @Override
672  public int getMaxIndexLength() throws SQLException {
673  HEAVYDBLOGGER.debug("Entered");
674  return 0;
675  }
676 
677  @Override
678  public int getMaxSchemaNameLength() throws SQLException {
679  HEAVYDBLOGGER.debug("Entered");
680  return 0;
681  }
682 
683  @Override
684  public int getMaxProcedureNameLength() throws SQLException {
685  HEAVYDBLOGGER.debug("Entered");
686  return 0;
687  }
688 
689  @Override
690  public int getMaxCatalogNameLength() throws SQLException {
691  HEAVYDBLOGGER.debug("Entered");
692  return 0;
693  }
694 
695  @Override
696  public int getMaxRowSize() throws SQLException {
697  HEAVYDBLOGGER.debug("Entered");
698  return 0;
699  }
700 
701  @Override
702  public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
703  HEAVYDBLOGGER.debug("Entered");
704  return false;
705  }
706 
707  @Override
708  public int getMaxStatementLength() throws SQLException {
709  HEAVYDBLOGGER.debug("Entered");
710  return 0;
711  }
712 
713  @Override
714  public int getMaxStatements() throws SQLException {
715  HEAVYDBLOGGER.debug("Entered");
716  return 0;
717  }
718 
719  @Override
720  public int getMaxTableNameLength() throws SQLException {
721  HEAVYDBLOGGER.debug("Entered");
722  return 0;
723  }
724 
725  @Override
726  public int getMaxTablesInSelect() throws SQLException {
727  HEAVYDBLOGGER.debug("Entered");
728  return 0;
729  }
730 
731  @Override
732  public int getMaxUserNameLength() throws SQLException {
733  HEAVYDBLOGGER.debug("Entered");
734  return 0;
735  }
736 
737  @Override
738  public int getDefaultTransactionIsolation() throws SQLException {
739  HEAVYDBLOGGER.debug("Entered");
740  return Connection.TRANSACTION_NONE;
741  }
742 
743  @Override
744  public boolean supportsTransactions() throws SQLException {
745  HEAVYDBLOGGER.debug("Entered");
746  return false;
747  }
748 
749  @Override
750  public boolean supportsTransactionIsolationLevel(int level) throws SQLException {
751  HEAVYDBLOGGER.debug("Entered");
752  return false;
753  }
754 
755  @Override
757  throws SQLException {
758  HEAVYDBLOGGER.debug("Entered");
759  return false;
760  }
761 
762  @Override
763  public boolean supportsDataManipulationTransactionsOnly() throws SQLException {
764  HEAVYDBLOGGER.debug("Entered");
765  return false;
766  }
767 
768  @Override
769  public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
770  HEAVYDBLOGGER.debug("Entered");
771  return false;
772  }
773 
774  @Override
775  public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
776  HEAVYDBLOGGER.debug("Entered");
777  return false;
778  }
779 
780  @Override
781  public ResultSet getProcedures(
782  String catalog, String schemaPattern, String procedureNamePattern)
783  throws SQLException {
784  HEAVYDBLOGGER.debug("Entered");
785  return null;
786  // throw new UnsupportedOperationException("Not supported yet," + " line:" + new
787  // Throwable().getStackTrace()[0].
788  // getLineNumber() + " class:" + new
789  // Throwable().getStackTrace()[0].getClassName() + " method:" + new
790  // Throwable(). getStackTrace()[0].getMethodName());
791  }
792 
793  @Override
794  public ResultSet getProcedureColumns(String catalog,
795  String schemaPattern,
796  String procedureNamePattern,
797  String columnNamePattern) throws SQLException {
798  HEAVYDBLOGGER.debug("Entered");
799  throw new UnsupportedOperationException("Not supported yet,"
800  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
801  + " class:" + new Throwable().getStackTrace()[0].getClassName()
802  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
803  }
804 
805  /*
806  * Wrappers for creating new TColumnType. Required so that the Thrift struct
807  * can be modified without breaking code.
808  */
809  public TColumnType createTColumnType(String colName, TTypeInfo colType) {
810  return createTColumnType(colName, colType, false);
811  }
812 
813  public TColumnType createTColumnType(String colName, TTypeInfo colType, Boolean irk) {
814  TColumnType ct = new TColumnType();
815  ct.col_name = colName;
816  ct.col_type = colType;
817  ct.is_reserved_keyword = irk;
818  ct.is_system = false;
819  ct.is_physical = false;
820  return ct;
821  }
822 
823  /*
824  * Retrieves a description of the tables available in the given catalog. Only
825  * table
826  * descriptions matching the catalog, schema, table name and type criteria are
827  * returned. They
828  * are ordered by TABLE_TYPE, TABLE_CAT, TABLE_SCHEM and TABLE_NAME. Each table
829  * description
830  * has the following columns:
831  *
832  * TABLE_CAT String => table catalog (may be null)
833  * TABLE_SCHEM String => table schema (may be null)
834  * TABLE_NAME String => table name
835  * TABLE_TYPE String => table type. Typical types are "TABLE", "VIEW",
836  * "SYSTEM TABLE",
837  * "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". REMARKS String =>
838  * explanatory
839  * comment on the table TYPE_CAT String => the types catalog (may be null)
840  * TYPE_SCHEM String
841  * => the types schema (may be null) TYPE_NAME String => type name (may be null)
842  * SELF_REFERENCING_COL_NAME String => name of the designated "identifier"
843  * column of a typed
844  * table (may be null) REF_GENERATION String => specifies how values in
845  * SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER",
846  * "DERIVED". (may be
847  * null) Note: Some databases may not return information for all tables.
848  *
849  * Parameters:
850  * catalog - a catalog name; must match the catalog name as it is stored in the
851  * database; ""
852  * retrieves those without a catalog; null means that the catalog name should
853  * not be used to
854  * narrow the search schemaPattern - a schema name pattern; must match the
855  * schema name as it
856  * is stored in the database; "" retrieves those without a schema; null means
857  * that the schema
858  * name should not be used to narrow the search tableNamePattern - a table name
859  * pattern; must
860  * match the table name as it is stored in the database types - a list of table
861  * types, which
862  * must be from the list of table types returned from getTableTypes(),to
863  * include; null
864  * returns all types Returns: ResultSet - each row is a table description
865  * Throws:
866  * SQLException - if a database access error occurs
867  */
868  @Override
869  public ResultSet getTables(
870  String catalog, String schemaPattern, String tableNamePattern, String[] types)
871  throws SQLException {
872  HEAVYDBLOGGER.debug("Entered");
873 
874  List<String> tables;
875  try {
876  tables = con.client.get_tables_for_database(con.session, catalog);
877  } catch (TException ex) {
878  throw new SQLException("get_tables_for_database failed " + ex.toString());
879  }
880 
881  List<String> views;
882  try {
883  views = con.client.get_views(con.session);
884  } catch (TException ex) {
885  throw new SQLException("get_views failed " + ex.toString());
886  }
887 
888  TTypeInfo strTTI =
889  new TTypeInfo(TDatumType.STR, TEncodingType.NONE, false, false, 0, 0, 0);
890  TColumnType columns[] = {createTColumnType("TABLE_CAT", new TTypeInfo(strTTI)),
891  createTColumnType("TABLE_SCHEM", new TTypeInfo(strTTI)),
892  createTColumnType("TABLE_NAME", new TTypeInfo(strTTI)),
893  createTColumnType("TABLE_TYPE", new TTypeInfo(strTTI)),
894  createTColumnType("REMARKS", new TTypeInfo(strTTI)),
895  createTColumnType("TYPE_CAT", new TTypeInfo(strTTI)),
896  createTColumnType("TYPE_SCHEM", new TTypeInfo(strTTI)),
897  createTColumnType("TYPE_NAME", new TTypeInfo(strTTI)),
898  createTColumnType("SELF_REFERENCING_COL_NAME", new TTypeInfo(strTTI)),
899  createTColumnType("REF_GENERATION", new TTypeInfo(strTTI))};
900 
901  Map<String, ArrayList<String>> dataMap = new HashMap(columns.length);
902  Map<String, ArrayList<Boolean>> nullMap = new HashMap(columns.length);
903 
904  // create component to contain the meta data for the rows
905  // and create a container to store the data and the nul indicators
906  List<TColumnType> rowDesc = new ArrayList(columns.length);
907  for (TColumnType col : columns) {
908  rowDesc.add(col);
909  dataMap.put(col.col_name, new ArrayList());
910  nullMap.put(col.col_name, new ArrayList());
911  }
912  if (schemaPattern == null
913  || schemaPattern.toLowerCase().equals(con.getCatalog().toLowerCase())) {
914  // Now add some actual details for table name
915  for (String x : tables) {
916  dataMap.get("TABLE_NAME").add(x);
917  nullMap.get("TABLE_NAME").add(false);
918  nullMap.get("TABLE_SCHEM").add(true);
919  nullMap.get("TABLE_CAT").add(true);
920  if (views.contains(x) == true) {
921  dataMap.get("TABLE_TYPE").add("VIEW");
922  } else {
923  dataMap.get("TABLE_TYPE").add("TABLE");
924  }
925  nullMap.get("TABLE_TYPE").add(false);
926  nullMap.get("REMARKS").add(true);
927  nullMap.get("TYPE_CAT").add(true);
928  nullMap.get("TYPE_SCHEM").add(true);
929  nullMap.get("TYPE_NAME").add(true);
930  nullMap.get("SELF_REFERENCING_COL_NAME").add(true);
931  nullMap.get("REF_GENERATION").add(true);
932  }
933  }
934  List<TColumn> columnsList = new ArrayList(columns.length);
935 
936  for (TColumnType col : columns) {
937  TColumn schemaCol =
938  createTColumnData(dataMap.get(col.col_name), nullMap.get(col.col_name));
939  columnsList.add(schemaCol);
940  }
941 
942  // create a rowset for the result
943  TRowSet rowSet = new TRowSet(rowDesc, null, columnsList, true);
944 
945  TQueryResult result = new TQueryResult(
946  rowSet, 0, 0, null, null, true, ai.heavy.thrift.server.TQueryType.UNKNOWN);
947 
948  HeavyAIResultSet tab = new HeavyAIResultSet(result, "GetTables");
949  return tab;
950  }
951 
952  // need to add type to this currently only does str type
953  private TColumn createTColumnData(Object data, List<Boolean> nullsList) {
954  TColumnData colData = new TColumnData();
955  colData.setStr_col((List<String>) data);
956 
957  TColumn col = new TColumn(colData, nullsList);
958  return col;
959  }
960 
961  @Override
962  public ResultSet getSchemas() throws SQLException {
963  HEAVYDBLOGGER.debug("Entered");
964 
965  List<TDBInfo> databases = null;
966 
967  try {
968  databases = con.client.get_databases(con.session);
969  } catch (TException ex) {
970  throw new SQLException("get_database failed " + ex.toString());
971  }
972 
973  // process info from databses into the resultset,
974  // then place in regular return from HEAVY.AI
975  TTypeInfo strTTI =
976  new TTypeInfo(TDatumType.STR, TEncodingType.NONE, false, false, 0, 0, 0);
977  TColumnType columns[] = {createTColumnType("TABLE_SCHEM", new TTypeInfo(strTTI)),
978  createTColumnType("TABLE_CATALOG", new TTypeInfo(strTTI))};
979  // create component to contain the meta data for the rows
980  List<TColumnType> rowDesc = new ArrayList();
981  for (TColumnType col : columns) {
982  rowDesc.add(col);
983  }
984 
985  // Now add some actual details for schema name
986  List<String> schemaList = new ArrayList();
987  List<Boolean> nullList = new ArrayList();
988  List<Boolean> catalogNullList = new ArrayList();
989 
990  for (TDBInfo x : databases) {
991  schemaList.add(x.db_name);
992  nullList.add(false);
993  catalogNullList.add(true);
994  }
995 
996  TColumnData colData = new TColumnData();
997  colData.setStr_col(schemaList);
998 
999  TColumn schemaCol = new TColumn(colData, nullList);
1000  TColumn catalogCol = new TColumn(null, catalogNullList);
1001 
1002  List<TColumn> columnsList = new ArrayList();
1003  columnsList.add(schemaCol);
1004  columnsList.add(catalogCol);
1005 
1006  // create a rowset for the result
1007  TRowSet rowSet = new TRowSet(rowDesc, null, columnsList, true);
1008 
1009  TQueryResult result = new TQueryResult(
1010  rowSet, 0, 0, null, null, true, ai.heavy.thrift.server.TQueryType.UNKNOWN);
1011 
1012  HeavyAIResultSet schemas = new HeavyAIResultSet(result, "getSchemas");
1013  return schemas;
1014  }
1015 
1016  @Override
1017  public ResultSet getCatalogs() throws SQLException {
1018  HEAVYDBLOGGER.debug("Entered");
1019  return getSchemas();
1020  }
1021 
1022  @Override
1023  public ResultSet getTableTypes() throws SQLException {
1024  HEAVYDBLOGGER.debug("Entered");
1025 
1026  TTypeInfo strTTI =
1027  new TTypeInfo(TDatumType.STR, TEncodingType.NONE, false, false, 0, 0, 0);
1028  TColumnType columns[] = {createTColumnType("TABLE_TYPE", new TTypeInfo(strTTI))};
1029 
1030  Map<String, HeavyAIData> dataMap = new HashMap(columns.length);
1031 
1032  // create component to contain the meta data for the rows
1033  // and create a container to store the data and the nul indicators
1034  List<TColumnType> rowDesc = new ArrayList(columns.length);
1035  for (TColumnType col : columns) {
1036  rowDesc.add(col);
1037  dataMap.put(col.col_name, new HeavyAIData(col.col_type.type));
1038  }
1039 
1040  // Now add some actual details for table name
1041  dataMap.get("TABLE_TYPE").add("TABLE");
1042  dataMap.get("TABLE_TYPE").add("VIEW");
1043 
1044  List<TColumn> columnsList = new ArrayList(columns.length);
1045 
1046  for (TColumnType col : columns) {
1047  TColumn schemaCol = dataMap.get(col.col_name).getTColumn();
1048  columnsList.add(schemaCol);
1049  }
1050 
1051  // create a rowset for the result
1052  TRowSet rowSet = new TRowSet(rowDesc, null, columnsList, true);
1053 
1054  TQueryResult result = new TQueryResult(
1055  rowSet, 0, 0, null, null, true, ai.heavy.thrift.server.TQueryType.UNKNOWN);
1056 
1057  HeavyAIResultSet tab = new HeavyAIResultSet(result, "getTableTypes");
1058 
1059  // logger.info("Dump result "+ result.toString());
1060  return tab;
1061  }
1062 
1063  /*
1064  * Retrieves a description of table columns available in the specified catalog.
1065  * Only column descriptions matching the catalog, schema, table and column name
1066  * criteria are
1067  * returned. They are ordered by TABLE_CAT,TABLE_SCHEM, TABLE_NAME, and
1068  * ORDINAL_POSITION.
1069  *
1070  * Each column description has the following columns:
1071  *
1072  * TABLE_CAT String => table catalog (may be null)
1073  * TABLE_SCHEM String => table schema (may be null)
1074  * TABLE_NAME String => table name
1075  * COLUMN_NAME String => column name
1076  * DATA_TYPE int => SQL type from java.sql.Types
1077  * TYPE_NAME String => Data source dependent type name, for a UDT the type name
1078  * is fully
1079  * qualified COLUMN_SIZE int => column size. BUFFER_LENGTH is not used.
1080  * DECIMAL_DIGITS int =>
1081  * the number of fractional digits. Null is returned for data types where
1082  * DECIMAL_DIGITS is
1083  * not applicable. NUM_PREC_RADIX int => Radix (typically either 10 or 2)
1084  * NULLABLE int => is
1085  * NULL allowed. columnNoNulls - might not allow NULL values columnNullable -
1086  * definitely
1087  * allows NULL values columnNullableUnknown - nullability unknown REMARKS String
1088  * => comment
1089  * describing column (may be null) COLUMN_DEF String => default value for the
1090  * column, which
1091  * should be interpreted as a string when the value is enclosed in single quotes
1092  * (may be
1093  * null) SQL_DATA_TYPE int => unused SQL_DATETIME_SUB int => unused
1094  * CHAR_OCTET_LENGTH int =>
1095  * for char types the maximum number of bytes in the column ORDINAL_POSITION int
1096  * => index of
1097  * column in table (starting at 1) IS_NULLABLE String => ISO rules are used to
1098  * determine the
1099  * nullability for a column. YES --- if the column can include NULLs NO --- if
1100  * the column
1101  * cannot include NULLs empty string --- if the nullability for the column is
1102  * unknown
1103  * SCOPE_CATALOG String => catalog of table that is the scope of a reference
1104  * attribute (null
1105  * if DATA_TYPE isn't REF) SCOPE_SCHEMA String => schema of table that is the
1106  * scope of a
1107  * reference attribute (null if the DATA_TYPE isn't REF) SCOPE_TABLE String =>
1108  * table name
1109  * that this the scope of a reference attribute (null if the DATA_TYPE isn't
1110  * REF)
1111  * SOURCE_DATA_TYPE short => source type of a distinct type or user-generated
1112  * Ref type, SQL
1113  * type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated
1114  * REF)
1115  * IS_AUTOINCREMENT String => Indicates whether this column is auto incremented
1116  * YES --- if the column is auto incremented
1117  * NO --- if the column is not auto incremented
1118  * empty string --- if it cannot be determined whether the column is auto
1119  * incremented
1120  * IS_GENERATEDCOLUMN String => Indicates whether this is a generated column
1121  * YES --- if this a generated column
1122  * NO --- if this not a generated column
1123  * empty string --- if it cannot be determined whether this is a generated
1124  * column
1125  * The COLUMN_SIZE column specifies the column size for the given column. For
1126  * numeric data,
1127  * this is the maximum precision. For character data, this is the length in
1128  * characters. For
1129  * datetime datatypes, this is the length in characters of the String
1130  * representation
1131  * (assuming the maximum allowed precision of the fractional seconds component).
1132  * For binary
1133  * data, this is the length in bytes. For the ROWID datatype, this is the length
1134  * in bytes.
1135  * Null is returned for data types where the column size is not applicable.
1136  *
1137  * Parameters:
1138  * catalog - a catalog name; must match the catalog name as it is stored in the
1139  * database; ""
1140  * retrieves those without a catalog; null means that the catalog name should
1141  * not be used to
1142  * narrow the search schemaPattern - a schema name pattern; must match the
1143  * schema name as it
1144  * is stored in the database; "" retrieves those without a schema; null means
1145  * that the schema
1146  * name should not be used to narrow the search tableNamePattern - a table name
1147  * pattern; must
1148  * match the table name as it is stored in the database columnNamePattern - a
1149  * column name
1150  * pattern; must match the column name as it is stored in the database Returns:
1151  * ResultSet -
1152  * each row is a column description Throws: SQLException - if a database access
1153  * error occurs
1154  */
1155  @Override
1156  public ResultSet getColumns(String catalog,
1157  String schemaPattern,
1158  String tableNamePattern,
1159  String columnNamePattern) throws SQLException {
1160  HEAVYDBLOGGER.debug("Entered");
1161  HEAVYDBLOGGER.debug("TablePattern " + tableNamePattern + " columnNamePattern "
1162  + columnNamePattern);
1163  String modifiedTablePattern = tableNamePattern.replaceAll("%", ".*");
1164  String modifiedColumnPattern =
1165  (columnNamePattern == null) ? null : columnNamePattern.replaceAll("%", ".*");
1166 
1167  HEAVYDBLOGGER.debug("TablePattern " + tableNamePattern + " modifiedColumnPattern "
1168  + modifiedColumnPattern);
1169 
1170  // declare the columns in the result set
1171  TTypeInfo strTTI =
1172  new TTypeInfo(TDatumType.STR, TEncodingType.NONE, false, false, 0, 0, 0);
1173  TTypeInfo intTTI =
1174  new TTypeInfo(TDatumType.INT, TEncodingType.NONE, false, false, 0, 0, 0);
1175  TTypeInfo smallIntTTI =
1176  new TTypeInfo(TDatumType.SMALLINT, TEncodingType.NONE, false, false, 0, 0, 0);
1177  TColumnType columns[] = {createTColumnType("TABLE_CAT", new TTypeInfo(strTTI)),
1178  createTColumnType("TABLE_SCHEM", new TTypeInfo(strTTI)),
1179  createTColumnType("TABLE_NAME", new TTypeInfo(strTTI)),
1180  createTColumnType("COLUMN_NAME", new TTypeInfo(strTTI)),
1181  createTColumnType("DATA_TYPE", new TTypeInfo(intTTI)),
1182  createTColumnType("TYPE_NAME", new TTypeInfo(strTTI)),
1183  createTColumnType("COLUMN_SIZE", new TTypeInfo(intTTI)),
1184  createTColumnType("BUFFER_LENGTH", new TTypeInfo(strTTI)),
1185  createTColumnType("DECIMAL_DIGITS", new TTypeInfo(intTTI)),
1186  createTColumnType("NUM_PREC_RADIX", new TTypeInfo(intTTI)),
1187  createTColumnType("NULLABLE", new TTypeInfo(intTTI)),
1188  createTColumnType("REMARKS", new TTypeInfo(strTTI)),
1189  createTColumnType("COLUMN_DEF", new TTypeInfo(strTTI)),
1190  createTColumnType("SQL_DATA_TYPE", new TTypeInfo(intTTI)),
1191  createTColumnType("SQL_DATETIME_SUB", new TTypeInfo(intTTI)),
1192  createTColumnType("CHAR_OCTET_LENGTH", new TTypeInfo(intTTI)),
1193  createTColumnType("ORDINAL_POSITION", new TTypeInfo(intTTI)),
1194  createTColumnType("IS_NULLABLE", new TTypeInfo(strTTI)),
1195  createTColumnType("SCOPE_CATALOG", new TTypeInfo(strTTI)),
1196  createTColumnType("SCOPE_SCHEMA", new TTypeInfo(strTTI)),
1197  createTColumnType("SCOPE_TABLE", new TTypeInfo(strTTI)),
1198  createTColumnType("SOURCE_DATA_TYPE", new TTypeInfo(smallIntTTI)),
1199  createTColumnType("IS_AUTOINCREMENT", new TTypeInfo(strTTI)),
1200  createTColumnType("IS_GENERATEDCOLUMN", new TTypeInfo(strTTI))};
1201 
1202  Map<String, HeavyAIData> dataMap = new HashMap(columns.length);
1203 
1204  // create component to contain the meta data for the rows
1205  // and create a container to store the data and the nul indicators
1206  List<TColumnType> rowDesc = new ArrayList(columns.length);
1207  for (TColumnType col : columns) {
1208  rowDesc.add(col);
1209  dataMap.put(col.col_name, new HeavyAIData(col.col_type.type));
1210  }
1211 
1212  // Now add some actual details for table name
1213  List<String> tables;
1214  try {
1215  tables = con.client.get_tables_for_database(con.session, catalog);
1216  } catch (TException ex) {
1217  throw new SQLException("get_tables_for_database failed " + ex.toString());
1218  }
1219 
1220  for (String tableName : tables) {
1221  // check if the table matches the input pattern
1222  if (tableNamePattern == null || tableNamePattern.equals(tableName)) {
1223  // grab meta data for table
1224  TTableDetails tableDetails;
1225  try {
1226  tableDetails = con.client.get_table_details(con.session, tableName);
1227  } catch (TException ex) {
1228  throw new SQLException("get_table_details failed " + ex.toString());
1229  }
1230 
1231  int ordinal = 0;
1232  // iterate through the columns
1233  for (TColumnType value : tableDetails.row_desc) {
1234  ordinal++;
1235  if (columnNamePattern == null
1236  || value.col_name.matches(modifiedColumnPattern)) {
1237  dataMap.get("TABLE_CAT").setNull(true);
1238  dataMap.get("TABLE_SCHEM").setNull(true);
1239  dataMap.get("TABLE_NAME").add(tableName);
1240  dataMap.get("COLUMN_NAME").add(value.col_name);
1241  dataMap.get("DATA_TYPE").add(HeavyAIType.toJava(value.col_type.type));
1242  dataMap.get("TYPE_NAME")
1243  .add((value.col_type.type.name()
1244  + (value.col_type.is_array ? "[]" : "")));
1245  if (value.col_type.type == TDatumType.DECIMAL) {
1246  dataMap.get("COLUMN_SIZE").add(value.col_type.precision);
1247  } else {
1248  dataMap.get("COLUMN_SIZE").add(100);
1249  }
1250  dataMap.get("BUFFER_LENGTH").setNull(true);
1251  if (value.col_type.type == TDatumType.DECIMAL) {
1252  dataMap.get("DECIMAL_DIGITS").add(value.col_type.scale);
1253  } else {
1254  dataMap.get("DECIMAL_DIGITS").setNull(true);
1255  }
1256  dataMap.get("NUM_PREC_RADIX").add(10);
1257  dataMap.get("NULLABLE")
1258  .add(value.col_type.nullable ? DatabaseMetaData.columnNullable
1259  : DatabaseMetaData.columnNoNulls);
1260  dataMap.get("REMARKS").add(" ");
1261  dataMap.get("COLUMN_DEF").setNull(true);
1262  dataMap.get("SQL_DATA_TYPE").add(0);
1263  dataMap.get("SQL_DATETIME_SUB").setNull(true);
1264  dataMap.get("CHAR_OCTET_LENGTH").add(0);
1265  dataMap.get("ORDINAL_POSITION").add(ordinal);
1266  dataMap.get("IS_NULLABLE").add(value.col_type.nullable ? "YES" : "NO");
1267  dataMap.get("SCOPE_CATALOG").setNull(true);
1268  dataMap.get("SCOPE_SCHEMA").setNull(true);
1269  dataMap.get("SCOPE_TABLE").setNull(true);
1270  dataMap.get("SOURCE_DATA_TYPE").add(HeavyAIType.toJava(value.col_type.type));
1271  dataMap.get("IS_AUTOINCREMENT").add("NO");
1272  dataMap.get("IS_GENERATEDCOLUMN").add("NO");
1273  }
1274  }
1275  }
1276  }
1277 
1278  List<TColumn> columnsList = new ArrayList(columns.length);
1279 
1280  for (TColumnType col : columns) {
1281  TColumn schemaCol = dataMap.get(col.col_name).getTColumn();
1282  // logger.info("Tcolumn is "+ schemaCol.toString());
1283  columnsList.add(schemaCol);
1284  }
1285 
1286  // create a rowset for the result
1287  TRowSet rowSet = new TRowSet(rowDesc, null, columnsList, true);
1288 
1289  TQueryResult result = new TQueryResult(
1290  rowSet, 0, 0, null, null, true, ai.heavy.thrift.server.TQueryType.UNKNOWN);
1291 
1292  HeavyAIResultSet cols = new HeavyAIResultSet(result, "getColumns");
1293  return cols;
1294  }
1295 
1296  @Override
1297  public ResultSet getColumnPrivileges(
1298  String catalog, String schema, String table, String columnNamePattern)
1299  throws SQLException {
1300  HEAVYDBLOGGER.debug("Entered");
1301  throw new UnsupportedOperationException("Not supported yet,"
1302  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1303  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1304  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1305  }
1306 
1307  public ResultSet getEmptyResultSet() {
1308  return new HeavyAIResultSet();
1309  }
1310 
1311  // this method is needed to build an empty resultset with columns names and
1312  // datatypes
1313  public ResultSet getEmptyResultSetWithDesc(TColumnType columns[])
1314  throws SQLException { // for compatibility and future
1315  Map<String, HeavyAIData> dataMap = new HashMap(columns.length);
1316  List<TColumnType> rowDesc = new ArrayList(columns.length);
1317  for (TColumnType col : columns) {
1318  rowDesc.add(col);
1319  dataMap.put(col.col_name, new HeavyAIData(col.col_type.type));
1320  }
1321  List<TColumn> columnsList = new ArrayList(columns.length);
1322  for (TColumnType col : columns) {
1323  TColumn schemaCol = dataMap.get(col.col_name).getTColumn();
1324  columnsList.add(schemaCol);
1325  }
1326  TRowSet rowSet = new TRowSet(rowDesc, null, columnsList, true);
1327  TQueryResult result = new TQueryResult(
1328  rowSet, 0, 0, null, null, true, ai.heavy.thrift.server.TQueryType.UNKNOWN);
1329  HeavyAIResultSet cols = new HeavyAIResultSet(result, "getColumns");
1330  return cols;
1331  }
1332 
1333  private void tablePermProcess(
1334  List<String> tables, Map<String, HeavyAIData> dataMap, String tableNamePattern)
1335  throws TException {
1336  for (String table : tables) {
1337  if (tableNamePattern != null && !table.matches(tableNamePattern)) {
1338  continue;
1339  }
1340  List<TDBObject> db_objects = con.client.get_db_object_privs(
1341  con.session, table, TDBObjectType.TableDBObjectType);
1342 
1343  // check if the table matches the input pattern
1344  for (TDBObject db_object : db_objects) {
1345  // If the user is a super user then the objectName will be super
1346  // and needs to be changed to the table name.
1347  if (db_object.objectName.equalsIgnoreCase("super")) {
1348  db_object.objectName = table;
1349  }
1350  // A bunch of db objects come back. Any with a different name throw away
1351  if (!db_object.objectName.equalsIgnoreCase(table)) {
1352  continue;
1353  }
1354 
1355  // Create set of table permissions based ont he db_object. This seems to
1356  // be the only way - though being hardwired on the number of privs is not great.
1357  TTablePermissions tt = new TTablePermissions(db_object.privs.get(0),
1358  db_object.privs.get(1),
1359  db_object.privs.get(2),
1360  db_object.privs.get(3),
1361  db_object.privs.get(4),
1362  db_object.privs.get(5),
1363  db_object.privs.get(6),
1364  db_object.privs.get(7));
1365 
1366  int ordinal = 1;
1367  for (TTablePermissions._Fields field = tt.fieldForId(ordinal); field != null;
1368  field = tt.fieldForId(++ordinal)) {
1369  Boolean x = (Boolean) tt.getFieldValue(field);
1370  if (x == false) {
1371  continue;
1372  }
1373  // standardise the fieldName upper case and remove trailing '_'. create_ =>
1374  // CREATE
1375  dataMap.get("PRIVILEGE")
1376  .add(field.getFieldName().toUpperCase().replace("_", ""));
1377  dataMap.get("TABLE_CAT").setNull(true);
1378  dataMap.get("TABLE_SCHEM").setNull(true);
1379  dataMap.get("TABLE_NAME").add(db_object.objectName);
1380  dataMap.get("GRANTOR").setNull(true);
1381  dataMap.get("GRANTEE").add(db_object.grantee);
1382  dataMap.get("IS_GRANTABLE").add("NO");
1383  }
1384  }
1385  }
1386  }
1387 
1388  @Override
1389  public ResultSet getTablePrivileges(
1390  String catalog, String schemaPattern, String tableNamePattern)
1391  throws SQLException {
1392  HEAVYDBLOGGER.debug("Entered");
1393 
1394  String modifiedTablePattern =
1395  (tableNamePattern == null) ? null : tableNamePattern.replaceAll("%", ".*");
1396 
1397  HEAVYDBLOGGER.debug("TablePattern " + tableNamePattern + " modifiedTableNamePattern "
1398  + modifiedTablePattern);
1399 
1400  // declare the columns in the result set
1401  final TTypeInfo strTTI =
1402  new TTypeInfo(TDatumType.STR, TEncodingType.NONE, false, false, 0, 0, 0);
1403  final TDatumType datumType = strTTI.type;
1404 
1405  Map<String, HeavyAIData> dataMap = new HashMap() {
1406  {
1407  put("TABLE_CAT", new HeavyAIData(datumType));
1408  put("TABLE_SCHEM", new HeavyAIData(datumType));
1409  put("TABLE_NAME", new HeavyAIData(datumType));
1410  put("GRANTOR", new HeavyAIData(datumType));
1411  put("GRANTEE", new HeavyAIData(datumType));
1412  put("PRIVILEGE", new HeavyAIData(datumType));
1413  put("IS_GRANTABLE", new HeavyAIData(datumType));
1414  }
1415  };
1416 
1417  try {
1418  // Get all the tables and then pattern match them in tablePermProcess
1419  List<String> tables = con.client.get_tables(con.session);
1420  tablePermProcess(tables, dataMap, modifiedTablePattern);
1421  } catch (TException ex) {
1422  throw new SQLException("get_privileges failed " + ex.toString());
1423  }
1424 
1425  // create component to contain the meta data for the rows
1426  // and create a container to store the data and the nul indicators
1427  // List<TColumnType> rowDesc = new ArrayList(columns.length);
1428 
1429  List<TColumnType> rowDesc = new ArrayList(dataMap.size());
1430  List<TColumn> columnsList = new ArrayList(dataMap.size());
1431 
1432  for (Map.Entry<String, HeavyAIData> pair : dataMap.entrySet()) {
1433  columnsList.add(pair.getValue().getTColumn());
1434  rowDesc.add(createTColumnType(pair.getKey(), new TTypeInfo(strTTI)));
1435  }
1436 
1437  // create a rowset for the result
1438  TRowSet rowSet = new TRowSet(rowDesc, null, columnsList, true);
1439 
1440  TQueryResult result = new TQueryResult(
1441  rowSet, 0, 0, null, null, true, ai.heavy.thrift.server.TQueryType.UNKNOWN);
1442 
1443  HeavyAIResultSet cols = new HeavyAIResultSet(result, "getPrivileges");
1444  return cols;
1445  }
1446 
1447  @Override
1448  public ResultSet getBestRowIdentifier(
1449  String catalog, String schema, String table, int scope, boolean nullable)
1450  throws SQLException {
1451  HEAVYDBLOGGER.debug("Entered");
1452  throw new UnsupportedOperationException("Not supported yet,"
1453  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1454  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1455  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1456  }
1457 
1458  @Override
1459  public ResultSet getVersionColumns(String catalog, String schema, String table)
1460  throws SQLException {
1461  HEAVYDBLOGGER.debug("Entered");
1462  throw new UnsupportedOperationException("Not supported yet,"
1463  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1464  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1465  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1466  }
1467 
1468  @Override
1469  public ResultSet getPrimaryKeys(String catalog, String schema, String table)
1470  throws SQLException {
1471  HEAVYDBLOGGER.debug("Entered");
1472 
1473  TTypeInfo strTTI =
1474  new TTypeInfo(TDatumType.STR, TEncodingType.NONE, false, false, 0, 0, 0);
1475  TTypeInfo intTTI =
1476  new TTypeInfo(TDatumType.INT, TEncodingType.NONE, false, false, 0, 0, 0);
1477  TTypeInfo smallIntTTI =
1478  new TTypeInfo(TDatumType.SMALLINT, TEncodingType.NONE, false, false, 0, 0, 0);
1479  TColumnType columns[] = {createTColumnType("TABLE_CAT", new TTypeInfo(strTTI)),
1480  createTColumnType("TABLE_SCHEM", new TTypeInfo(strTTI)),
1481  createTColumnType("TABLE_NAME", new TTypeInfo(strTTI)),
1482  createTColumnType("COLUMN_NAME", new TTypeInfo(strTTI)),
1483  createTColumnType("KEY_SEQ", new TTypeInfo(smallIntTTI)),
1484  createTColumnType("PK_NAME", new TTypeInfo(strTTI))};
1485 
1486  return getEmptyResultSetWithDesc(columns);
1487  }
1488 
1489  @Override
1490  public ResultSet getImportedKeys(String catalog, String schema, String table)
1491  throws SQLException {
1492  HEAVYDBLOGGER.debug("Entered");
1493 
1494  TTypeInfo strTTI =
1495  new TTypeInfo(TDatumType.STR, TEncodingType.NONE, false, false, 0, 0, 0);
1496  TTypeInfo intTTI =
1497  new TTypeInfo(TDatumType.INT, TEncodingType.NONE, false, false, 0, 0, 0);
1498  TTypeInfo smallIntTTI =
1499  new TTypeInfo(TDatumType.SMALLINT, TEncodingType.NONE, false, false, 0, 0, 0);
1500  TColumnType columns[] = {createTColumnType("PKTABLE_CAT", new TTypeInfo(strTTI)),
1501  createTColumnType("PKTABLE_SCHEM", new TTypeInfo(strTTI)),
1502  createTColumnType("PKTABLE_NAME", new TTypeInfo(strTTI)),
1503  createTColumnType("PKCOLUMN_NAME", new TTypeInfo(strTTI)),
1504  createTColumnType("FKTABLE_CAT", new TTypeInfo(strTTI)),
1505  createTColumnType("FKTABLE_SCHEM", new TTypeInfo(strTTI)),
1506  createTColumnType("FKTABLE_NAME", new TTypeInfo(strTTI)),
1507  createTColumnType("FKCOLUMN_NAME", new TTypeInfo(strTTI)),
1508  createTColumnType("KEY_SEQ", new TTypeInfo(smallIntTTI)),
1509  createTColumnType("UPDATE_RULE", new TTypeInfo(smallIntTTI)),
1510  createTColumnType("DELETE_RULE", new TTypeInfo(smallIntTTI)),
1511  createTColumnType("FK_NAME", new TTypeInfo(strTTI)),
1512  createTColumnType("PK_NAME", new TTypeInfo(strTTI)),
1513  createTColumnType("DEFERRABILITY", new TTypeInfo(smallIntTTI))};
1514 
1515  return getEmptyResultSetWithDesc(columns);
1516  }
1517 
1518  @Override
1519  public ResultSet getExportedKeys(String catalog, String schema, String table)
1520  throws SQLException {
1521  HEAVYDBLOGGER.debug("Entered");
1522 
1523  TTypeInfo strTTI =
1524  new TTypeInfo(TDatumType.STR, TEncodingType.NONE, false, false, 0, 0, 0);
1525  TTypeInfo intTTI =
1526  new TTypeInfo(TDatumType.INT, TEncodingType.NONE, false, false, 0, 0, 0);
1527  TTypeInfo smallIntTTI =
1528  new TTypeInfo(TDatumType.SMALLINT, TEncodingType.NONE, false, false, 0, 0, 0);
1529  TColumnType columns[] = {createTColumnType("FKTABLE_CAT", new TTypeInfo(strTTI)),
1530  createTColumnType("FKTABLE_SCHEM", new TTypeInfo(strTTI)),
1531  createTColumnType("FKTABLE_NAME", new TTypeInfo(strTTI)),
1532  createTColumnType("FKCOLUMN_NAME", new TTypeInfo(strTTI)),
1533  createTColumnType("PKTABLE_CAT", new TTypeInfo(strTTI)),
1534  createTColumnType("PKTABLE_SCHEM", new TTypeInfo(strTTI)),
1535  createTColumnType("PKTABLE_NAME", new TTypeInfo(strTTI)),
1536  createTColumnType("PKCOLUMN_NAME", new TTypeInfo(strTTI)),
1537  createTColumnType("KEY_SEQ", new TTypeInfo(smallIntTTI)),
1538  createTColumnType("UPDATE_RULE", new TTypeInfo(smallIntTTI)),
1539  createTColumnType("DELETE_RULE", new TTypeInfo(smallIntTTI)),
1540  createTColumnType("PK_NAME", new TTypeInfo(strTTI)),
1541  createTColumnType("FK_NAME", new TTypeInfo(strTTI)),
1542  createTColumnType("DEFERRABILITY", new TTypeInfo(smallIntTTI))};
1543 
1544  return getEmptyResultSetWithDesc(columns);
1545  }
1546 
1547  @Override
1548  public ResultSet getCrossReference(String parentCatalog,
1549  String parentSchema,
1550  String parentTable,
1551  String foreignCatalog,
1552  String foreignSchema,
1553  String foreignTable) throws SQLException {
1554  HEAVYDBLOGGER.debug("Entered");
1555  throw new UnsupportedOperationException("Not supported yet,"
1556  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1557  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1558  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1559  }
1560 
1561  /*
1562  * Retrieves a description of all the data types supported by this database.
1563  * They are
1564  * ordered by DATA_TYPE and then by how closely the data type maps to the
1565  * corresponding JDBC
1566  * SQL type. If the database supports SQL distinct types, then getTypeInfo()
1567  * will return a
1568  * single row with a TYPE_NAME of DISTINCT and a DATA_TYPE of Types.DISTINCT. If
1569  * the database
1570  * supports SQL structured types, then getTypeInfo() will return a single row
1571  * with a
1572  * TYPE_NAME of STRUCT and a DATA_TYPE of Types.STRUCT.
1573  *
1574  * If SQL distinct or structured types are supported, then information on the
1575  * individual
1576  * types may be obtained from the getUDTs() method.
1577  *
1578  * Each type description has the following columns:
1579  *
1580  * TYPE_NAME String => Type name
1581  * DATA_TYPE int => SQL data type from java.sql.Types
1582  * PRECISION int => maximum precision
1583  * LITERAL_PREFIX String => prefix used to quote a literal (may be null)
1584  * LITERAL_SUFFIX String => suffix used to quote a literal (may be null)
1585  * CREATE_PARAMS String => parameters used in creating the type (may be null)
1586  * NULLABLE short => can you use NULL for this type.
1587  * typeNoNulls - does not allow NULL values
1588  * typeNullable - allows NULL values
1589  * typeNullableUnknown - nullability unknown
1590  * CASE_SENSITIVE boolean=> is it case sensitive.
1591  * SEARCHABLE short => can you use "WHERE" based on this type:
1592  * typePredNone - No support
1593  * typePredChar - Only supported with WHERE .. LIKE
1594  * typePredBasic - Supported except for WHERE .. LIKE
1595  * typeSearchable - Supported for all WHERE ..
1596  * UNSIGNED_ATTRIBUTE boolean => is it unsigned.
1597  * FIXED_PREC_SCALE boolean => can it be a money value.
1598  * AUTO_INCREMENT boolean => can it be used for an auto-increment value.
1599  * LOCAL_TYPE_NAME String => localized version of type name (may be null)
1600  * MINIMUM_SCALE short => minimum scale supported
1601  * MAXIMUM_SCALE short => maximum scale supported
1602  * SQL_DATA_TYPE int => unused
1603  * SQL_DATETIME_SUB int => unused
1604  * NUM_PREC_RADIX int => usually 2 or 10
1605  * The PRECISION column represents the maximum column size that the server
1606  * supports for the
1607  * given datatype. For numeric data, this is the maximum precision. For
1608  * character data, this
1609  * is the length in characters. For datetime datatypes, this is the length in
1610  * characters of
1611  * the String representation (assuming the maximum allowed precision of the
1612  * fractional
1613  * seconds component). For binary data, this is the length in bytes. For the
1614  * ROWID datatype,
1615  * this is the length in bytes. Null is returned for data types where the column
1616  * size is not
1617  * applicable.
1618  *
1619  * Returns:
1620  * a ResultSet object in which each row is an SQL type description
1621  * Throws:
1622  * SQLException - if a database access error occurs
1623  */
1624  @Override
1625  public ResultSet getTypeInfo() throws SQLException {
1626  HEAVYDBLOGGER.debug("Entered");
1627 
1628  // declare the columns in the result set
1629  TTypeInfo strTTI =
1630  new TTypeInfo(TDatumType.STR, TEncodingType.NONE, false, false, 0, 0, 0);
1631  TTypeInfo intTTI =
1632  new TTypeInfo(TDatumType.INT, TEncodingType.NONE, false, false, 0, 0, 0);
1633  TTypeInfo smallIntTTI =
1634  new TTypeInfo(TDatumType.SMALLINT, TEncodingType.NONE, false, false, 0, 0, 0);
1635  TTypeInfo boolTTI =
1636  new TTypeInfo(TDatumType.BOOL, TEncodingType.NONE, false, false, 0, 0, 0);
1637  TColumnType columns[] = {createTColumnType("TYPE_NAME", new TTypeInfo(strTTI)),
1638  createTColumnType("DATA_TYPE", new TTypeInfo(intTTI)),
1639  createTColumnType("PRECISION", new TTypeInfo(intTTI)),
1640  createTColumnType("LITERAL_PREFIX", new TTypeInfo(strTTI)),
1641  createTColumnType("LITERAL_SUFFIX", new TTypeInfo(strTTI)),
1642  createTColumnType("CREATE_PARAMS", new TTypeInfo(strTTI)),
1643  createTColumnType("NULLABLE", new TTypeInfo(smallIntTTI)),
1644  createTColumnType("CASE_SENSITIVE", new TTypeInfo(boolTTI)),
1645  createTColumnType("SEARCHABLE", new TTypeInfo(smallIntTTI)),
1646  createTColumnType("UNSIGNED_ATTRIBUTE", new TTypeInfo(boolTTI)),
1647  createTColumnType("FIXED_PREC_SCALE", new TTypeInfo(boolTTI)),
1648  createTColumnType("AUTO_INCREMENT", new TTypeInfo(boolTTI)),
1649  createTColumnType("LOCAL_TYPE_NAME", new TTypeInfo(strTTI)),
1650  createTColumnType("MINIMUM_SCALE", new TTypeInfo(smallIntTTI)),
1651  createTColumnType("MAXIMUM_SCALE", new TTypeInfo(smallIntTTI)),
1652  createTColumnType("SQL_DATA_TYPE", new TTypeInfo(intTTI)),
1653  createTColumnType("SQL_DATETIME_SUB", new TTypeInfo(intTTI)),
1654  createTColumnType("NUM_PREC_RADIX", new TTypeInfo(intTTI))};
1655 
1656  Map<String, HeavyAIData> dataMap = new HashMap(columns.length);
1657 
1658  // create component to contain the meta data for the rows
1659  // and create a container to store the data and the nul indicators
1660  List<TColumnType> rowDesc = new ArrayList(columns.length);
1661  for (TColumnType col : columns) {
1662  rowDesc.add(col);
1663  dataMap.put(col.col_name, new HeavyAIData(col.col_type.type));
1664  }
1665  // TODO this is currently a work in progress need to add actual details here
1666  // Now add some actual details for table name
1667  dataMap.get("TYPE_NAME").setNull(true); // String => Type name
1668  dataMap.get("DATA_TYPE").setNull(true); // int => SQL data type from java.sql.Types
1669  dataMap.get("PRECISION").setNull(true); // int => maximum precision
1670  dataMap.get("LITERAL_PREFIX").setNull(true); // .setNull(true);// String => prefix
1671  // used to quote a literal (may be null)
1672  dataMap.get("LITERAL_SUFFIX").setNull(true); // .setNull(true);// String => suffix
1673  // used to quote a literal (may be null)
1674  dataMap.get("CREATE_PARAMS")
1675  .setNull(
1676  true); // String => parameters used in creating the type (may be null)
1677  dataMap.get("NULLABLE").setNull(true); // short => can you use NULL for this type.
1678  // typeNoNulls - does not allow NULL values
1679  // typeNullable - allows NULL values
1680  // typeNullableUnknown - nullability unknown
1681  dataMap.get("CASE_SENSITIVE").setNull(true); // boolean=> is it case sensitive.
1682  dataMap.get("SEARCHABLE")
1683  .setNull(true); // short => can you use "WHERE" based on this type:
1684  // typePredNone - No support
1685  // typePredChar - Only supported with WHERE .. LIKE
1686  // typePredBasic - Supported except for WHERE .. LIKE
1687  // typeSearchable - Supported for all WHERE ..
1688  dataMap.get("UNSIGNED_ATTRIBUTE").setNull(true); // boolean => is it unsigned.
1689  dataMap.get("FIXED_PREC_SCALE").setNull(true); // boolean => can it be a money value.
1690  dataMap.get("AUTO_INCREMENT")
1691  .setNull(false); // boolean => can it be used for an auto-increment value.
1692  dataMap.get("LOCAL_TYPE_NAME")
1693  .setNull(true); // String => localized version of type name (may be null)
1694  dataMap.get("MINIMUM_SCALE").setNull(true); // short => minimum scale supported
1695  dataMap.get("MAXIMUM_SCALE").setNull(true); // short => maximum scale supported
1696  dataMap.get("SQL_DATA_TYPE").setNull(true); // int => unused
1697  dataMap.get("SQL_DATETIME_SUB").setNull(true); // int => unused
1698  dataMap.get("NUM_PREC_RADIX").setNull(true); //
1699 
1700  List<TColumn> columnsList = new ArrayList(columns.length);
1701 
1702  for (TColumnType col : columns) {
1703  TColumn schemaCol = dataMap.get(col.col_name).getTColumn();
1704  // logger.info("Tcolumn is "+ schemaCol.toString());
1705  columnsList.add(schemaCol);
1706  }
1707 
1708  // create a rowset for the result
1709  TRowSet rowSet = new TRowSet(rowDesc, null, columnsList, true);
1710 
1711  TQueryResult result = new TQueryResult(
1712  rowSet, 0, 0, null, null, true, ai.heavy.thrift.server.TQueryType.UNKNOWN);
1713 
1714  HeavyAIResultSet cols = new HeavyAIResultSet(result, "getTypeInfo");
1715  return cols;
1716  }
1717 
1718  @Override
1719  public ResultSet getIndexInfo(String catalog,
1720  String schema,
1721  String table,
1722  boolean unique,
1723  boolean approximate) throws SQLException {
1724  HEAVYDBLOGGER.debug("Entered");
1725  return getEmptyResultSet();
1726  }
1727 
1728  @Override
1729  public boolean supportsResultSetType(int type) throws SQLException {
1730  HEAVYDBLOGGER.debug("Entered");
1731  return false;
1732  }
1733 
1734  @Override
1735  public boolean supportsResultSetConcurrency(int type, int concurrency)
1736  throws SQLException {
1737  HEAVYDBLOGGER.debug("Entered");
1738  return false;
1739  }
1740 
1741  @Override
1742  public boolean ownUpdatesAreVisible(int type) throws SQLException {
1743  HEAVYDBLOGGER.debug("Entered");
1744  return false;
1745  }
1746 
1747  @Override
1748  public boolean ownDeletesAreVisible(int type) throws SQLException {
1749  HEAVYDBLOGGER.debug("Entered");
1750  return false;
1751  }
1752 
1753  @Override
1754  public boolean ownInsertsAreVisible(int type) throws SQLException {
1755  HEAVYDBLOGGER.debug("Entered");
1756  return false;
1757  }
1758 
1759  @Override
1760  public boolean othersUpdatesAreVisible(int type) throws SQLException {
1761  HEAVYDBLOGGER.debug("Entered");
1762  return false;
1763  }
1764 
1765  @Override
1766  public boolean othersDeletesAreVisible(int type) throws SQLException {
1767  HEAVYDBLOGGER.debug("Entered");
1768  return false;
1769  }
1770 
1771  @Override
1772  public boolean othersInsertsAreVisible(int type) throws SQLException {
1773  HEAVYDBLOGGER.debug("Entered");
1774  return false;
1775  }
1776 
1777  @Override
1778  public boolean updatesAreDetected(int type) throws SQLException {
1779  HEAVYDBLOGGER.debug("Entered");
1780  return false;
1781  }
1782 
1783  @Override
1784  public boolean deletesAreDetected(int type) throws SQLException {
1785  HEAVYDBLOGGER.debug("Entered");
1786  return false;
1787  }
1788 
1789  @Override
1790  public boolean insertsAreDetected(int type) throws SQLException {
1791  HEAVYDBLOGGER.debug("Entered");
1792  return false;
1793  }
1794 
1795  @Override
1796  public boolean supportsBatchUpdates() throws SQLException {
1797  HEAVYDBLOGGER.debug("Entered");
1798  return true;
1799  }
1800 
1801  @Override
1802  public ResultSet getUDTs(
1803  String catalog, String schemaPattern, String typeNamePattern, int[] types)
1804  throws SQLException {
1805  HEAVYDBLOGGER.debug("Entered");
1806  throw new UnsupportedOperationException("Not supported yet,"
1807  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1808  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1809  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1810  }
1811 
1812  @Override
1813  public Connection getConnection() throws SQLException {
1814  HEAVYDBLOGGER.debug("Entered");
1815  return con;
1816  }
1817 
1818  @Override
1819  public boolean supportsSavepoints() throws SQLException {
1820  HEAVYDBLOGGER.debug("Entered");
1821  return false;
1822  }
1823 
1824  @Override
1825  public boolean supportsNamedParameters() throws SQLException {
1826  HEAVYDBLOGGER.debug("Entered");
1827  return false;
1828  }
1829 
1830  @Override
1831  public boolean supportsMultipleOpenResults() throws SQLException {
1832  HEAVYDBLOGGER.debug("Entered");
1833  return false;
1834  }
1835 
1836  @Override
1837  public boolean supportsGetGeneratedKeys() throws SQLException {
1838  HEAVYDBLOGGER.debug("Entered");
1839  return false;
1840  }
1841 
1842  @Override
1843  public ResultSet getSuperTypes(
1844  String catalog, String schemaPattern, String typeNamePattern)
1845  throws SQLException {
1846  HEAVYDBLOGGER.debug("Entered");
1847  throw new UnsupportedOperationException("Not supported yet,"
1848  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1849  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1850  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1851  }
1852 
1853  @Override
1854  public ResultSet getSuperTables(
1855  String catalog, String schemaPattern, String tableNamePattern)
1856  throws SQLException {
1857  HEAVYDBLOGGER.debug("Entered");
1858  throw new UnsupportedOperationException("Not supported yet,"
1859  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1860  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1861  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1862  }
1863 
1864  @Override
1865  public ResultSet getAttributes(String catalog,
1866  String schemaPattern,
1867  String typeNamePattern,
1868  String attributeNamePattern) throws SQLException {
1869  HEAVYDBLOGGER.debug("Entered");
1870  throw new UnsupportedOperationException("Not supported yet,"
1871  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1872  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1873  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1874  }
1875 
1876  @Override
1877  public boolean supportsResultSetHoldability(int holdability) throws SQLException {
1878  HEAVYDBLOGGER.debug("Entered");
1879  return false;
1880  }
1881 
1882  @Override
1883  public int getResultSetHoldability() throws SQLException {
1884  HEAVYDBLOGGER.debug("Entered");
1885  return ResultSet.CLOSE_CURSORS_AT_COMMIT;
1886  }
1887 
1888  @Override
1889  public int getDatabaseMajorVersion() throws SQLException {
1890  HEAVYDBLOGGER.debug("Entered");
1891  return this.databaseMajorVersion;
1892  }
1893 
1894  @Override
1895  public int getDatabaseMinorVersion() throws SQLException {
1896  HEAVYDBLOGGER.debug("Entered");
1897  return this.databaseMinorVersion;
1898  }
1899 
1900  @Override
1901  public int getJDBCMajorVersion() throws SQLException {
1902  HEAVYDBLOGGER.debug("Entered");
1903  return 0;
1904  }
1905 
1906  @Override
1907  public int getJDBCMinorVersion() throws SQLException { // logger.debug("Entered");
1908  HEAVYDBLOGGER.debug("Entered");
1909  return 0;
1910  }
1911 
1912  @Override
1913  public int getSQLStateType() throws SQLException {
1914  HEAVYDBLOGGER.debug("Entered");
1915  return 0;
1916  }
1917 
1918  @Override
1919  public boolean locatorsUpdateCopy() throws SQLException {
1920  HEAVYDBLOGGER.debug("Entered");
1921  return false;
1922  }
1923 
1924  @Override
1925  public boolean supportsStatementPooling() throws SQLException {
1926  HEAVYDBLOGGER.debug("Entered");
1927  return false;
1928  }
1929 
1930  @Override
1931  public RowIdLifetime getRowIdLifetime() throws SQLException {
1932  HEAVYDBLOGGER.debug("Entered");
1933  return RowIdLifetime.ROWID_VALID_OTHER;
1934  }
1935 
1936  @Override
1937  public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
1938  HEAVYDBLOGGER.debug("Entered");
1939  return getSchemas();
1940  }
1941 
1942  @Override
1943  public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
1944  HEAVYDBLOGGER.debug("Entered");
1945  return false;
1946  }
1947 
1948  @Override
1949  public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
1950  HEAVYDBLOGGER.debug("Entered");
1951  return false;
1952  }
1953 
1954  @Override
1955  public ResultSet getClientInfoProperties() throws SQLException {
1956  HEAVYDBLOGGER.debug("Entered");
1957  throw new UnsupportedOperationException("Not supported yet,"
1958  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1959  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1960  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1961  }
1962 
1963  @Override
1964  public ResultSet getFunctions(
1965  String catalog, String schemaPattern, String functionNamePattern)
1966  throws SQLException {
1967  HEAVYDBLOGGER.debug("Entered");
1968  throw new UnsupportedOperationException("Not supported yet,"
1969  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1970  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1971  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1972  }
1973 
1974  @Override
1975  public ResultSet getFunctionColumns(String catalog,
1976  String schemaPattern,
1977  String functionNamePattern,
1978  String columnNamePattern) throws SQLException {
1979  HEAVYDBLOGGER.debug("Entered");
1980  throw new UnsupportedOperationException("Not supported yet,"
1981  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1982  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1983  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1984  }
1985 
1986  @Override
1987  public ResultSet getPseudoColumns(String catalog,
1988  String schemaPattern,
1989  String tableNamePattern,
1990  String columnNamePattern) throws SQLException {
1991  HEAVYDBLOGGER.debug("Entered");
1992  throw new UnsupportedOperationException("Not supported yet,"
1993  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
1994  + " class:" + new Throwable().getStackTrace()[0].getClassName()
1995  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
1996  }
1997 
1998  @Override
1999  public boolean generatedKeyAlwaysReturned() throws SQLException {
2000  HEAVYDBLOGGER.debug("Entered");
2001  return false;
2002  }
2003 
2004  @Override
2005  public <T> T unwrap(Class<T> iface) throws SQLException {
2006  HEAVYDBLOGGER.debug("Entered");
2007  return null;
2008  }
2009 
2010  @Override
2011  public boolean isWrapperFor(Class<?> iface) throws SQLException {
2012  HEAVYDBLOGGER.debug("Entered");
2013  return false;
2014  }
2015 }
static int toJava(TDatumType type)
ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern)
ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern)
ResultSet getVersionColumns(String catalog, String schema, String table)
ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern)
ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern)
ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern)
TColumnType createTColumnType(String colName, TTypeInfo colType, Boolean irk)
ResultSet getImportedKeys(String catalog, String schema, String table)
void tablePermProcess(List< String > tables, Map< String, HeavyAIData > dataMap, String tableNamePattern)
ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)
ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable)
ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable)
boolean supportsConvert(int fromType, int toType)
ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types)
ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
TColumnType createTColumnType(String colName, TTypeInfo colType)
ResultSet getPrimaryKeys(String catalog, String schema, String table)
ResultSet getEmptyResultSetWithDesc(TColumnType columns[])
ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern)
HeavyAIDatabaseMetaData(HeavyAIConnection connection)
ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern)
TColumn createTColumnData(Object data, List< Boolean > nullsList)
ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern)
ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern)
ResultSet getSchemas(String catalog, String schemaPattern)
boolean supportsResultSetConcurrency(int type, int concurrency)
ResultSet getExportedKeys(String catalog, String schema, String table)