PageRenderTime 66ms CodeModel.GetById 13ms app.highlight 46ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.2.0-rc0/hive/external/jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java

#
Java | 1090 lines | 832 code | 205 blank | 53 comment | 53 complexity | 56558270d04032201545028f556d44b7 MD5 | raw file
   1/**
   2 * Licensed to the Apache Software Foundation (ASF) under one
   3 * or more contributor license agreements.  See the NOTICE file
   4 * distributed with this work for additional information
   5 * regarding copyright ownership.  The ASF licenses this file
   6 * to you under the Apache License, Version 2.0 (the
   7 * "License"); you may not use this file except in compliance
   8 * with the License.  You may obtain a copy of the License at
   9 *
  10 *     http://www.apache.org/licenses/LICENSE-2.0
  11 *
  12 * Unless required by applicable law or agreed to in writing, software
  13 * distributed under the License is distributed on an "AS IS" BASIS,
  14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15 * See the License for the specific language governing permissions and
  16 * limitations under the License.
  17 */
  18
  19package org.apache.hadoop.hive.jdbc;
  20
  21import java.sql.Connection;
  22import java.sql.DatabaseMetaData;
  23import java.sql.ResultSet;
  24import java.sql.RowIdLifetime;
  25import java.sql.SQLException;
  26import java.util.ArrayList;
  27import java.util.Arrays;
  28import java.util.Collections;
  29import java.util.Comparator;
  30import java.util.List;
  31import java.util.jar.Attributes;
  32
  33import org.apache.hadoop.hive.metastore.TableType;
  34import org.apache.hadoop.hive.metastore.api.FieldSchema;
  35import org.apache.hadoop.hive.metastore.api.Table;
  36import org.apache.hadoop.hive.service.HiveInterface;
  37import org.apache.thrift.TException;
  38
  39/**
  40 * HiveDatabaseMetaData.
  41 *
  42 */
  43public class HiveDatabaseMetaData implements java.sql.DatabaseMetaData {
  44
  45  private final HiveInterface client;
  46  private static final String CATALOG_SEPARATOR = ".";
  47
  48  private static final char SEARCH_STRING_ESCAPE = '\\';
  49
  50  //  The maximum column length = MFieldSchema.FNAME in metastore/src/model/package.jdo
  51  private static final int maxColumnNameLength = 128;
  52
  53  /**
  54   *
  55   */
  56  public HiveDatabaseMetaData(HiveInterface client) {
  57    this.client = client;
  58  }
  59
  60  public boolean allProceduresAreCallable() throws SQLException {
  61    throw new SQLException("Method not supported");
  62  }
  63
  64  public boolean allTablesAreSelectable() throws SQLException {
  65    return true;
  66  }
  67
  68  public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
  69    throw new SQLException("Method not supported");
  70  }
  71
  72  public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
  73    throw new SQLException("Method not supported");
  74  }
  75
  76  public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
  77    throw new SQLException("Method not supported");
  78  }
  79
  80  public boolean deletesAreDetected(int type) throws SQLException {
  81    throw new SQLException("Method not supported");
  82  }
  83
  84  public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
  85    throw new SQLException("Method not supported");
  86  }
  87
  88  public ResultSet getAttributes(String catalog, String schemaPattern,
  89      String typeNamePattern, String attributeNamePattern) throws SQLException {
  90    throw new SQLException("Method not supported");
  91  }
  92
  93  public ResultSet getBestRowIdentifier(String catalog, String schema,
  94      String table, int scope, boolean nullable) throws SQLException {
  95    throw new SQLException("Method not supported");
  96  }
  97
  98  public String getCatalogSeparator() throws SQLException {
  99    return CATALOG_SEPARATOR;
 100  }
 101
 102  public String getCatalogTerm() throws SQLException {
 103    return "database";
 104  }
 105
 106  public ResultSet getCatalogs() throws SQLException {
 107    try {
 108      // TODO a client call to get the schema's after HIVE-675 is implemented
 109      final List<String> catalogs = new ArrayList();
 110      catalogs.add("default");
 111      return new HiveMetaDataResultSet<String>(Arrays.asList("TABLE_CAT")
 112              , Arrays.asList("STRING")
 113              , catalogs) {
 114        private int cnt = 0;
 115
 116        public boolean next() throws SQLException {
 117          if (cnt<data.size()) {
 118            List<Object> a = new ArrayList<Object>(1);
 119            a.add(data.get(cnt)); // TABLE_CAT String => table catalog (may be null)
 120            row = a;
 121            cnt++;
 122            return true;
 123          } else {
 124            return false;
 125          }
 126        }
 127      };
 128    } catch (Exception e) {
 129      throw new SQLException(e);
 130    }
 131  }
 132
 133  public ResultSet getClientInfoProperties() throws SQLException {
 134    throw new SQLException("Method not supported");
 135  }
 136
 137  public ResultSet getColumnPrivileges(String catalog, String schema,
 138      String table, String columnNamePattern) throws SQLException {
 139    throw new SQLException("Method not supported");
 140  }
 141
 142  /**
 143   * Convert a pattern containing JDBC catalog search wildcards into
 144   * Java regex patterns.
 145   *
 146   * @param pattern input which may contain '%' or '_' wildcard characters, or
 147   * these characters escaped using {@link #getSearchStringEscape()}.
 148   * @return replace %/_ with regex search characters, also handle escaped
 149   * characters.
 150   */
 151  private String convertPattern(final String pattern) {
 152    if (pattern==null) {
 153      return ".*";
 154    } else {
 155      StringBuilder result = new StringBuilder(pattern.length());
 156
 157      boolean escaped = false;
 158      for (int i = 0, len = pattern.length(); i < len; i++) {
 159        char c = pattern.charAt(i);
 160        if (escaped) {
 161          if (c != SEARCH_STRING_ESCAPE) {
 162            escaped = false;
 163          }
 164          result.append(c);
 165        } else {
 166          if (c == SEARCH_STRING_ESCAPE) {
 167            escaped = true;
 168            continue;
 169          } else if (c == '%') {
 170            result.append(".*");
 171          } else if (c == '_') {
 172            result.append('.');
 173          } else {
 174            result.append(c);
 175          }
 176        }
 177      }
 178
 179      return result.toString();
 180    }
 181  }
 182
 183  public ResultSet getColumns(String catalog, final String schemaPattern
 184          , final String tableNamePattern
 185          , final String columnNamePattern) throws SQLException {
 186    List<JdbcColumn> columns = new ArrayList<JdbcColumn>();
 187    try {
 188      if (catalog==null) {
 189        catalog = "default";
 190      }
 191
 192      String regtableNamePattern = convertPattern(tableNamePattern);
 193      String regcolumnNamePattern = convertPattern(columnNamePattern);
 194
 195      List<String> tables = client.get_tables(catalog, "*");
 196      for (String table: tables) {
 197        if (table.matches(regtableNamePattern)) {
 198          List<FieldSchema> fields = client.get_fields(catalog, table);
 199          int ordinalPos = 1;
 200          for (FieldSchema field: fields) {
 201            if (field.getName().matches(regcolumnNamePattern)) {
 202              columns.add(new JdbcColumn(field.getName(), table, catalog
 203                      , field.getType(), field.getComment(), ordinalPos));
 204              ordinalPos++;
 205            }
 206          }
 207        }
 208      }
 209      Collections.sort(columns, new GetColumnsComparator());
 210
 211      return new HiveMetaDataResultSet<JdbcColumn>(
 212              Arrays.asList("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE"
 213                      , "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS"
 214                      , "NUM_PREC_RADIX", "NULLABLE", "REMARKS", "COLUMN_DEF", "SQL_DATA_TYPE"
 215                      , "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", "ORDINAL_POSITION"
 216                      , "IS_NULLABLE", "SCOPE_CATLOG", "SCOPE_SCHEMA", "SCOPE_TABLE"
 217                      , "SOURCE_DATA_TYPE")
 218              , Arrays.asList("STRING", "STRING", "STRING", "STRING", "I32", "STRING"
 219                , "I32", "I32", "I32", "I32", "I32", "STRING"
 220                , "STRING", "I32", "I32", "I32", "I32"
 221                , "STRING", "STRING", "STRING", "STRING", "I32")
 222              , columns) {
 223
 224        private int cnt = 0;
 225
 226        public boolean next() throws SQLException {
 227          if (cnt<data.size()) {
 228            List<Object> a = new ArrayList<Object>(20);
 229            JdbcColumn column = data.get(cnt);
 230            a.add(column.getTableCatalog()); // TABLE_CAT String => table catalog (may be null)
 231            a.add(null); // TABLE_SCHEM String => table schema (may be null)
 232            a.add(column.getTableName()); // TABLE_NAME String => table name
 233            a.add(column.getColumnName()); // COLUMN_NAME String => column name
 234            a.add(column.getSqlType()); // DATA_TYPE short => SQL type from java.sql.Types
 235            a.add(column.getType()); // TYPE_NAME String => Data source dependent type name.
 236            a.add(column.getColumnSize()); // COLUMN_SIZE int => column size.
 237            a.add(null); // BUFFER_LENGTH is not used.
 238            a.add(column.getDecimalDigits()); // DECIMAL_DIGITS int => number of fractional digits
 239            a.add(column.getNumPrecRadix()); // NUM_PREC_RADIX int => typically either 10 or 2
 240            a.add(DatabaseMetaData.columnNullable); // NULLABLE int => is NULL allowed?
 241            a.add(column.getComment()); // REMARKS String => comment describing column (may be null)
 242            a.add(null); // COLUMN_DEF String => default value (may be null)
 243            a.add(null); // SQL_DATA_TYPE int => unused
 244            a.add(null); // SQL_DATETIME_SUB int => unused
 245            a.add(null); // CHAR_OCTET_LENGTH int
 246            a.add(column.getOrdinalPos()); // ORDINAL_POSITION int
 247            a.add("YES"); // IS_NULLABLE String
 248            a.add(null); // SCOPE_CATLOG String
 249            a.add(null); // SCOPE_SCHEMA String
 250            a.add(null); // SCOPE_TABLE String
 251            a.add(null); // SOURCE_DATA_TYPE short
 252            row = a;
 253            cnt++;
 254            return true;
 255          } else {
 256            return false;
 257          }
 258        }
 259      };
 260    } catch (Exception e) {
 261      throw new SQLException(e);
 262    }
 263  }
 264
 265  /**
 266   * We sort the output of getColumns to guarantee jdbc compliance.
 267   * First check by table name then by ordinal position
 268   */
 269  private class GetColumnsComparator implements Comparator<JdbcColumn> {
 270
 271    public int compare(JdbcColumn o1, JdbcColumn o2) {
 272      int compareName = o1.getTableName().compareTo(o2.getTableName());
 273      if (compareName==0) {
 274        if (o1.getOrdinalPos() > o2.getOrdinalPos()) {
 275          return 1;
 276        } else if (o1.getOrdinalPos() < o2.getOrdinalPos()) {
 277          return -1;
 278        }
 279        return 0;
 280      } else {
 281        return compareName;
 282      }
 283    }
 284  }
 285
 286  public Connection getConnection() throws SQLException {
 287    throw new SQLException("Method not supported");
 288  }
 289
 290  public ResultSet getCrossReference(String primaryCatalog,
 291      String primarySchema, String primaryTable, String foreignCatalog,
 292      String foreignSchema, String foreignTable) throws SQLException {
 293    throw new SQLException("Method not supported");
 294  }
 295
 296  public int getDatabaseMajorVersion() throws SQLException {
 297    throw new SQLException("Method not supported");
 298  }
 299
 300  public int getDatabaseMinorVersion() throws SQLException {
 301    throw new SQLException("Method not supported");
 302  }
 303
 304  public String getDatabaseProductName() throws SQLException {
 305    return "Hive";
 306  }
 307
 308  public String getDatabaseProductVersion() throws SQLException {
 309    try {
 310      return client.getVersion();
 311    } catch (TException e) {
 312      throw new SQLException(e);
 313    }
 314  }
 315
 316  public int getDefaultTransactionIsolation() throws SQLException {
 317    return Connection.TRANSACTION_NONE;
 318  }
 319
 320  public int getDriverMajorVersion() {
 321    return HiveDriver.getMajorDriverVersion();
 322  }
 323
 324  public int getDriverMinorVersion() {
 325    return HiveDriver.getMinorDriverVersion();
 326  }
 327
 328  public String getDriverName() throws SQLException {
 329    return HiveDriver.fetchManifestAttribute(Attributes.Name.IMPLEMENTATION_TITLE);
 330  }
 331
 332  public String getDriverVersion() throws SQLException {
 333    return HiveDriver.fetchManifestAttribute(Attributes.Name.IMPLEMENTATION_VERSION);
 334  }
 335
 336  public ResultSet getExportedKeys(String catalog, String schema, String table)
 337      throws SQLException {
 338    throw new SQLException("Method not supported");
 339  }
 340
 341  public String getExtraNameCharacters() throws SQLException {
 342    throw new SQLException("Method not supported");
 343  }
 344
 345  public ResultSet getFunctionColumns(String arg0, String arg1, String arg2,
 346      String arg3) throws SQLException {
 347    throw new SQLException("Method not supported");
 348  }
 349
 350  public ResultSet getFunctions(String arg0, String arg1, String arg2)
 351      throws SQLException {
 352    throw new SQLException("Method not supported");
 353  }
 354
 355  public String getIdentifierQuoteString() throws SQLException {
 356    throw new SQLException("Method not supported");
 357  }
 358
 359  public ResultSet getImportedKeys(String catalog, String schema, String table)
 360      throws SQLException {
 361    throw new SQLException("Method not supported");
 362  }
 363
 364  public ResultSet getIndexInfo(String catalog, String schema, String table,
 365      boolean unique, boolean approximate) throws SQLException {
 366    throw new SQLException("Method not supported");
 367  }
 368
 369  public int getJDBCMajorVersion() throws SQLException {
 370    return 3;
 371  }
 372
 373  public int getJDBCMinorVersion() throws SQLException {
 374    return 0;
 375  }
 376
 377  public int getMaxBinaryLiteralLength() throws SQLException {
 378    throw new SQLException("Method not supported");
 379  }
 380
 381  public int getMaxCatalogNameLength() throws SQLException {
 382    throw new SQLException("Method not supported");
 383  }
 384
 385  public int getMaxCharLiteralLength() throws SQLException {
 386    throw new SQLException("Method not supported");
 387  }
 388
 389  /**
 390   *  Returns the value of maxColumnNameLength.
 391   *
 392   *  @param int
 393   */
 394  public int getMaxColumnNameLength() throws SQLException {
 395    return maxColumnNameLength;
 396  }
 397
 398  public int getMaxColumnsInGroupBy() throws SQLException {
 399    throw new SQLException("Method not supported");
 400  }
 401
 402  public int getMaxColumnsInIndex() throws SQLException {
 403    throw new SQLException("Method not supported");
 404  }
 405
 406  public int getMaxColumnsInOrderBy() throws SQLException {
 407    throw new SQLException("Method not supported");
 408  }
 409
 410  public int getMaxColumnsInSelect() throws SQLException {
 411    throw new SQLException("Method not supported");
 412  }
 413
 414  public int getMaxColumnsInTable() throws SQLException {
 415    throw new SQLException("Method not supported");
 416  }
 417
 418  public int getMaxConnections() throws SQLException {
 419    throw new SQLException("Method not supported");
 420  }
 421
 422  public int getMaxCursorNameLength() throws SQLException {
 423    throw new SQLException("Method not supported");
 424  }
 425
 426  public int getMaxIndexLength() throws SQLException {
 427    throw new SQLException("Method not supported");
 428  }
 429
 430  public int getMaxProcedureNameLength() throws SQLException {
 431    throw new SQLException("Method not supported");
 432  }
 433
 434  public int getMaxRowSize() throws SQLException {
 435    throw new SQLException("Method not supported");
 436  }
 437
 438  public int getMaxSchemaNameLength() throws SQLException {
 439    throw new SQLException("Method not supported");
 440  }
 441
 442  public int getMaxStatementLength() throws SQLException {
 443    throw new SQLException("Method not supported");
 444  }
 445
 446  public int getMaxStatements() throws SQLException {
 447    throw new SQLException("Method not supported");
 448  }
 449
 450  public int getMaxTableNameLength() throws SQLException {
 451    throw new SQLException("Method not supported");
 452  }
 453
 454  public int getMaxTablesInSelect() throws SQLException {
 455    throw new SQLException("Method not supported");
 456  }
 457
 458  public int getMaxUserNameLength() throws SQLException {
 459    throw new SQLException("Method not supported");
 460  }
 461
 462  public String getNumericFunctions() throws SQLException {
 463    return "";
 464  }
 465
 466  public ResultSet getPrimaryKeys(String catalog, String schema, String table)
 467      throws SQLException {
 468    throw new SQLException("Method not supported");
 469  }
 470
 471  public ResultSet getProcedureColumns(String catalog, String schemaPattern,
 472      String procedureNamePattern, String columnNamePattern)
 473      throws SQLException {
 474    throw new SQLException("Method not supported");
 475  }
 476
 477  public String getProcedureTerm() throws SQLException {
 478    throw new SQLException("Method not supported");
 479  }
 480
 481  public ResultSet getProcedures(String catalog, String schemaPattern,
 482      String procedureNamePattern) throws SQLException {
 483    return null;
 484  }
 485
 486  public int getResultSetHoldability() throws SQLException {
 487    throw new SQLException("Method not supported");
 488  }
 489
 490  public RowIdLifetime getRowIdLifetime() throws SQLException {
 491    throw new SQLException("Method not supported");
 492  }
 493
 494  public String getSQLKeywords() throws SQLException {
 495    throw new SQLException("Method not supported");
 496  }
 497
 498  public int getSQLStateType() throws SQLException {
 499    return DatabaseMetaData.sqlStateSQL99;
 500  }
 501
 502  public String getSchemaTerm() throws SQLException {
 503    return "";
 504  }
 505
 506  public ResultSet getSchemas() throws SQLException {
 507    return getSchemas(null, null);
 508  }
 509
 510  public ResultSet getSchemas(String catalog, String schemaPattern)
 511      throws SQLException {
 512    return new HiveMetaDataResultSet(Arrays.asList("TABLE_SCHEM", "TABLE_CATALOG")
 513            , Arrays.asList("STRING", "STRING"), null) {
 514
 515      public boolean next() throws SQLException {
 516        return false;
 517      }
 518    };
 519
 520  }
 521
 522  public String getSearchStringEscape() throws SQLException {
 523    return String.valueOf(SEARCH_STRING_ESCAPE);
 524  }
 525
 526  public String getStringFunctions() throws SQLException {
 527    return "";
 528  }
 529
 530  public ResultSet getSuperTables(String catalog, String schemaPattern,
 531      String tableNamePattern) throws SQLException {
 532    throw new SQLException("Method not supported");
 533  }
 534
 535  public ResultSet getSuperTypes(String catalog, String schemaPattern,
 536      String typeNamePattern) throws SQLException {
 537    throw new SQLException("Method not supported");
 538  }
 539
 540  public String getSystemFunctions() throws SQLException {
 541    return "";
 542  }
 543
 544  public ResultSet getTablePrivileges(String catalog, String schemaPattern,
 545      String tableNamePattern) throws SQLException {
 546    throw new SQLException("Method not supported");
 547  }
 548
 549  public ResultSet getTableTypes() throws SQLException {
 550    final TableType[] tt = TableType.values();
 551    ResultSet result = new HiveMetaDataResultSet<TableType>(
 552            Arrays.asList("TABLE_TYPE")
 553            , Arrays.asList("STRING"), new ArrayList<TableType>(Arrays.asList(tt))) {
 554      private int cnt = 0;
 555
 556      public boolean next() throws SQLException {
 557        if (cnt<data.size()) {
 558          List<Object> a = new ArrayList<Object>(1);
 559          a.add(toJdbcTableType(data.get(cnt).name()));
 560          row = a;
 561          cnt++;
 562          return true;
 563        } else {
 564          return false;
 565        }
 566      }
 567    };
 568    return result;
 569  }
 570
 571  public ResultSet getTables(String catalog, String schemaPattern,
 572                             String tableNamePattern, String[] types) throws SQLException {
 573    final List<String> tablesstr;
 574    final List<JdbcTable> resultTables = new ArrayList();
 575    final String resultCatalog;
 576    if (catalog==null) { // On jdbc the default catalog is null but on hive it's "default"
 577      resultCatalog = "default";
 578    } else {
 579      resultCatalog = catalog;
 580    }
 581
 582    String regtableNamePattern = convertPattern(tableNamePattern);
 583    try {
 584      tablesstr = client.get_tables(resultCatalog, "*");
 585      for (String tablestr: tablesstr) {
 586        if (tablestr.matches(regtableNamePattern)) {
 587          Table tbl = client.get_table(resultCatalog, tablestr);
 588          if (types == null) {
 589            resultTables.add(new JdbcTable(resultCatalog, tbl.getTableName(), tbl.getTableType()
 590                    , tbl.getParameters().get("comment")));
 591          } else {
 592            String tableType = toJdbcTableType(tbl.getTableType());
 593            for(String type : types) {
 594              if (type.equalsIgnoreCase(tableType)) {
 595                resultTables.add(new JdbcTable(resultCatalog, tbl.getTableName(), tbl.getTableType()
 596                        , tbl.getParameters().get("comment")));
 597                break;
 598              }
 599            }
 600          }
 601        }
 602      }
 603      Collections.sort(resultTables, new GetTablesComparator());
 604    } catch (Exception e) {
 605      throw new SQLException(e);
 606    }
 607    ResultSet result = new HiveMetaDataResultSet<JdbcTable>(
 608            Arrays.asList("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "TABLE_TYPE", "REMARKS")
 609            , Arrays.asList("STRING", "STRING", "STRING", "STRING", "STRING")
 610            , resultTables) {
 611      private int cnt = 0;
 612
 613      public boolean next() throws SQLException {
 614        if (cnt<data.size()) {
 615          List<Object> a = new ArrayList<Object>(5);
 616          JdbcTable table = data.get(cnt);
 617          a.add(table.getTableCatalog()); // TABLE_CAT String => table catalog (may be null)
 618          a.add(null); // TABLE_SCHEM String => table schema (may be null)
 619          a.add(table.getTableName()); // TABLE_NAME String => table name
 620          try {
 621            a.add(table.getSqlTableType()); // TABLE_TYPE String => "TABLE","VIEW"
 622          } catch (Exception e) {
 623            throw new SQLException(e);
 624          }
 625          a.add(table.getComment()); // REMARKS String => explanatory comment on the table
 626          row = a;
 627          cnt++;
 628          return true;
 629        } else {
 630          return false;
 631        }
 632      }
 633
 634    };
 635    return result;
 636  }
 637
 638  /**
 639   * We sort the output of getTables to guarantee jdbc compliance.
 640   * First check by table type then by table name
 641   */
 642  private class GetTablesComparator implements Comparator<JdbcTable> {
 643
 644    public int compare(JdbcTable o1, JdbcTable o2) {
 645      int compareType = o1.getType().compareTo(o2.getType());
 646      if (compareType==0) {
 647        return o1.getTableName().compareTo(o2.getTableName());
 648      } else {
 649        return compareType;
 650      }
 651    }
 652  }
 653
 654  /**
 655   * Translate hive table types into jdbc table types.
 656   * @param hivetabletype
 657   * @return
 658   */
 659  public static String toJdbcTableType(String hivetabletype) {
 660    if (hivetabletype==null) {
 661      return null;
 662    } else if (hivetabletype.equals(TableType.MANAGED_TABLE.toString())) {
 663      return "TABLE";
 664    } else if (hivetabletype.equals(TableType.VIRTUAL_VIEW.toString())) {
 665      return "VIEW";
 666    } else if (hivetabletype.equals(TableType.EXTERNAL_TABLE.toString())) {
 667      return "EXTERNAL TABLE";
 668    } else {
 669      return hivetabletype;
 670    }
 671  }
 672
 673  public String getTimeDateFunctions() throws SQLException {
 674    return "";
 675  }
 676
 677  public ResultSet getTypeInfo() throws SQLException {
 678    throw new SQLException("Method not supported");
 679  }
 680
 681  public ResultSet getUDTs(String catalog, String schemaPattern,
 682      String typeNamePattern, int[] types) throws SQLException {
 683
 684    return new HiveMetaDataResultSet(
 685            Arrays.asList("TYPE_CAT", "TYPE_SCHEM", "TYPE_NAME", "CLASS_NAME", "DATA_TYPE"
 686                    , "REMARKS", "BASE_TYPE")
 687            , Arrays.asList("STRING", "STRING", "STRING", "STRING", "I32", "STRING", "I32")
 688            , null) {
 689
 690      public boolean next() throws SQLException {
 691        return false;
 692      }
 693    };
 694  }
 695
 696  public String getURL() throws SQLException {
 697    throw new SQLException("Method not supported");
 698  }
 699
 700  public String getUserName() throws SQLException {
 701    throw new SQLException("Method not supported");
 702  }
 703
 704  public ResultSet getVersionColumns(String catalog, String schema, String table)
 705      throws SQLException {
 706    throw new SQLException("Method not supported");
 707  }
 708
 709  public boolean insertsAreDetected(int type) throws SQLException {
 710    throw new SQLException("Method not supported");
 711  }
 712
 713  public boolean isCatalogAtStart() throws SQLException {
 714    throw new SQLException("Method not supported");
 715  }
 716
 717  public boolean isReadOnly() throws SQLException {
 718    throw new SQLException("Method not supported");
 719  }
 720
 721  public boolean locatorsUpdateCopy() throws SQLException {
 722    throw new SQLException("Method not supported");
 723  }
 724
 725  public boolean nullPlusNonNullIsNull() throws SQLException {
 726    throw new SQLException("Method not supported");
 727  }
 728
 729  public boolean nullsAreSortedAtEnd() throws SQLException {
 730    throw new SQLException("Method not supported");
 731  }
 732
 733  public boolean nullsAreSortedAtStart() throws SQLException {
 734    throw new SQLException("Method not supported");
 735  }
 736
 737  public boolean nullsAreSortedHigh() throws SQLException {
 738    throw new SQLException("Method not supported");
 739  }
 740
 741  public boolean nullsAreSortedLow() throws SQLException {
 742    throw new SQLException("Method not supported");
 743  }
 744
 745  public boolean othersDeletesAreVisible(int type) throws SQLException {
 746    throw new SQLException("Method not supported");
 747  }
 748
 749  public boolean othersInsertsAreVisible(int type) throws SQLException {
 750    throw new SQLException("Method not supported");
 751  }
 752
 753  public boolean othersUpdatesAreVisible(int type) throws SQLException {
 754    throw new SQLException("Method not supported");
 755  }
 756
 757  public boolean ownDeletesAreVisible(int type) throws SQLException {
 758    throw new SQLException("Method not supported");
 759  }
 760
 761  public boolean ownInsertsAreVisible(int type) throws SQLException {
 762    throw new SQLException("Method not supported");
 763  }
 764
 765  public boolean ownUpdatesAreVisible(int type) throws SQLException {
 766    throw new SQLException("Method not supported");
 767  }
 768
 769  public boolean storesLowerCaseIdentifiers() throws SQLException {
 770    throw new SQLException("Method not supported");
 771  }
 772
 773  public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
 774    throw new SQLException("Method not supported");
 775  }
 776
 777  public boolean storesMixedCaseIdentifiers() throws SQLException {
 778    throw new SQLException("Method not supported");
 779  }
 780
 781  public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
 782    throw new SQLException("Method not supported");
 783  }
 784
 785  public boolean storesUpperCaseIdentifiers() throws SQLException {
 786    throw new SQLException("Method not supported");
 787  }
 788
 789  public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
 790    throw new SQLException("Method not supported");
 791  }
 792
 793  public boolean supportsANSI92EntryLevelSQL() throws SQLException {
 794    throw new SQLException("Method not supported");
 795  }
 796
 797  public boolean supportsANSI92FullSQL() throws SQLException {
 798    throw new SQLException("Method not supported");
 799  }
 800
 801  public boolean supportsANSI92IntermediateSQL() throws SQLException {
 802    throw new SQLException("Method not supported");
 803  }
 804
 805  public boolean supportsAlterTableWithAddColumn() throws SQLException {
 806    return true;
 807  }
 808
 809  public boolean supportsAlterTableWithDropColumn() throws SQLException {
 810    return false;
 811  }
 812
 813  public boolean supportsBatchUpdates() throws SQLException {
 814    return false;
 815  }
 816
 817  public boolean supportsCatalogsInDataManipulation() throws SQLException {
 818    return false;
 819  }
 820
 821  public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
 822    return false;
 823  }
 824
 825  public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
 826    return false;
 827  }
 828
 829  public boolean supportsCatalogsInProcedureCalls() throws SQLException {
 830    return false;
 831  }
 832
 833  public boolean supportsCatalogsInTableDefinitions() throws SQLException {
 834    return false;
 835  }
 836
 837  public boolean supportsColumnAliasing() throws SQLException {
 838    return true;
 839  }
 840
 841  public boolean supportsConvert() throws SQLException {
 842    throw new SQLException("Method not supported");
 843  }
 844
 845  public boolean supportsConvert(int fromType, int toType) throws SQLException {
 846    throw new SQLException("Method not supported");
 847  }
 848
 849  public boolean supportsCoreSQLGrammar() throws SQLException {
 850    throw new SQLException("Method not supported");
 851  }
 852
 853  public boolean supportsCorrelatedSubqueries() throws SQLException {
 854    throw new SQLException("Method not supported");
 855  }
 856
 857  public boolean supportsDataDefinitionAndDataManipulationTransactions()
 858      throws SQLException {
 859    throw new SQLException("Method not supported");
 860  }
 861
 862  public boolean supportsDataManipulationTransactionsOnly() throws SQLException {
 863    throw new SQLException("Method not supported");
 864  }
 865
 866  public boolean supportsDifferentTableCorrelationNames() throws SQLException {
 867    throw new SQLException("Method not supported");
 868  }
 869
 870  public boolean supportsExpressionsInOrderBy() throws SQLException {
 871    throw new SQLException("Method not supported");
 872  }
 873
 874  public boolean supportsExtendedSQLGrammar() throws SQLException {
 875    throw new SQLException("Method not supported");
 876  }
 877
 878  public boolean supportsFullOuterJoins() throws SQLException {
 879    throw new SQLException("Method not supported");
 880  }
 881
 882  public boolean supportsGetGeneratedKeys() throws SQLException {
 883    throw new SQLException("Method not supported");
 884  }
 885
 886  public boolean supportsGroupBy() throws SQLException {
 887    return true;
 888  }
 889
 890  public boolean supportsGroupByBeyondSelect() throws SQLException {
 891    throw new SQLException("Method not supported");
 892  }
 893
 894  public boolean supportsGroupByUnrelated() throws SQLException {
 895    throw new SQLException("Method not supported");
 896  }
 897
 898  public boolean supportsIntegrityEnhancementFacility() throws SQLException {
 899    throw new SQLException("Method not supported");
 900  }
 901
 902  public boolean supportsLikeEscapeClause() throws SQLException {
 903    throw new SQLException("Method not supported");
 904  }
 905
 906  public boolean supportsLimitedOuterJoins() throws SQLException {
 907    throw new SQLException("Method not supported");
 908  }
 909
 910  public boolean supportsMinimumSQLGrammar() throws SQLException {
 911    throw new SQLException("Method not supported");
 912  }
 913
 914  public boolean supportsMixedCaseIdentifiers() throws SQLException {
 915    throw new SQLException("Method not supported");
 916  }
 917
 918  public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
 919    throw new SQLException("Method not supported");
 920  }
 921
 922  public boolean supportsMultipleOpenResults() throws SQLException {
 923    throw new SQLException("Method not supported");
 924  }
 925
 926  public boolean supportsMultipleResultSets() throws SQLException {
 927    return false;
 928  }
 929
 930  public boolean supportsMultipleTransactions() throws SQLException {
 931    throw new SQLException("Method not supported");
 932  }
 933
 934  public boolean supportsNamedParameters() throws SQLException {
 935    throw new SQLException("Method not supported");
 936  }
 937
 938  public boolean supportsNonNullableColumns() throws SQLException {
 939    return false;
 940  }
 941
 942  public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
 943    throw new SQLException("Method not supported");
 944  }
 945
 946  public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
 947    throw new SQLException("Method not supported");
 948  }
 949
 950  public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
 951    throw new SQLException("Method not supported");
 952  }
 953
 954  public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
 955    throw new SQLException("Method not supported");
 956  }
 957
 958  public boolean supportsOrderByUnrelated() throws SQLException {
 959    throw new SQLException("Method not supported");
 960  }
 961
 962  public boolean supportsOuterJoins() throws SQLException {
 963    return true;
 964  }
 965
 966  public boolean supportsPositionedDelete() throws SQLException {
 967    return false;
 968  }
 969
 970  public boolean supportsPositionedUpdate() throws SQLException {
 971    return false;
 972  }
 973
 974  public boolean supportsResultSetConcurrency(int type, int concurrency)
 975      throws SQLException {
 976    throw new SQLException("Method not supported");
 977  }
 978
 979  public boolean supportsResultSetHoldability(int holdability)
 980      throws SQLException {
 981    return false;
 982  }
 983
 984  public boolean supportsResultSetType(int type) throws SQLException {
 985    return true;
 986  }
 987
 988  public boolean supportsSavepoints() throws SQLException {
 989    return false;
 990  }
 991
 992  public boolean supportsSchemasInDataManipulation() throws SQLException {
 993    return false;
 994  }
 995
 996  public boolean supportsSchemasInIndexDefinitions() throws SQLException {
 997    return false;
 998  }
 999
1000  public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
1001    return false;
1002  }
1003
1004  public boolean supportsSchemasInProcedureCalls() throws SQLException {
1005    return false;
1006  }
1007
1008  public boolean supportsSchemasInTableDefinitions() throws SQLException {
1009    return false;
1010  }
1011
1012  public boolean supportsSelectForUpdate() throws SQLException {
1013    return false;
1014  }
1015
1016  public boolean supportsStatementPooling() throws SQLException {
1017    throw new SQLException("Method not supported");
1018  }
1019
1020  public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
1021    throw new SQLException("Method not supported");
1022  }
1023
1024  public boolean supportsStoredProcedures() throws SQLException {
1025    return false;
1026  }
1027
1028  public boolean supportsSubqueriesInComparisons() throws SQLException {
1029    throw new SQLException("Method not supported");
1030  }
1031
1032  public boolean supportsSubqueriesInExists() throws SQLException {
1033    throw new SQLException("Method not supported");
1034  }
1035
1036  public boolean supportsSubqueriesInIns() throws SQLException {
1037    throw new SQLException("Method not supported");
1038  }
1039
1040  public boolean supportsSubqueriesInQuantifieds() throws SQLException {
1041    throw new SQLException("Method not supported");
1042  }
1043
1044  public boolean supportsTableCorrelationNames() throws SQLException {
1045    throw new SQLException("Method not supported");
1046  }
1047
1048  public boolean supportsTransactionIsolationLevel(int level)
1049      throws SQLException {
1050    throw new SQLException("Method not supported");
1051  }
1052
1053  public boolean supportsTransactions() throws SQLException {
1054    return false;
1055  }
1056
1057  public boolean supportsUnion() throws SQLException {
1058    throw new SQLException("Method not supported");
1059  }
1060
1061  public boolean supportsUnionAll() throws SQLException {
1062    throw new SQLException("Method not supported");
1063  }
1064
1065  public boolean updatesAreDetected(int type) throws SQLException {
1066    throw new SQLException("Method not supported");
1067  }
1068
1069  public boolean usesLocalFilePerTable() throws SQLException {
1070    throw new SQLException("Method not supported");
1071  }
1072
1073  public boolean usesLocalFiles() throws SQLException {
1074    throw new SQLException("Method not supported");
1075  }
1076
1077  public boolean isWrapperFor(Class<?> iface) throws SQLException {
1078    throw new SQLException("Method not supported");
1079  }
1080
1081  public <T> T unwrap(Class<T> iface) throws SQLException {
1082    throw new SQLException("Method not supported");
1083  }
1084
1085  public static void main(String[] args) throws SQLException {
1086    HiveDatabaseMetaData meta = new HiveDatabaseMetaData(null);
1087    System.out.println("DriverName: " + meta.getDriverName());
1088    System.out.println("DriverVersion: " + meta.getDriverVersion());
1089  }
1090}