protocol = new TBinaryProtocol(transport); client = new ThriftHiveMetastore.Client(protocol); try { if (!transport.isOpen()) {
protocol = new TBinaryProtocol(transport); client = new ThriftHiveMetastore.Client(protocol); try { transport.open();
protocol = new TBinaryProtocol(transport); client = new ThriftHiveMetastore.Client(protocol); try { transport.open();
client = new ThriftHiveMetastore.Client(new TBinaryProtocol(transport)); try { transport.open();
client = new ThriftHiveMetastore.Client(protocol);
tbl = metaStoreClient.get_table(database, tableName); } else { final long currentTimeMillis = System.currentTimeMillis(); metaStoreClient.alter_table(database, tableName, tbl); } else { metaStoreClient.create_table(tbl);
/** * TODO. * * @param dbName TODO * @param tableName TODO * @return TODO * * @throws HiveMetastoreException TODO */ public synchronized Table getTable(String dbName, String tableName) throws HiveMetastoreException { try { connectIfNeeded(); return client.get_table(dbName, tableName); } catch (NoSuchObjectException e) { return null; } catch (TException e) { close(); throw new HiveMetastoreException(e); } }
/** * Create client from host and port with timeout * @param host Host to connect to * @param port Port to connect on * @param timeoutMillis Socket timeout * @return Hive Thrift Metastore client * @throws TTransportException Connection errors */ public static ThriftHiveMetastore.Iface create(String host, int port, int timeoutMillis) throws TTransportException { if (TEST_CLIENT != null) { return TEST_CLIENT; } TTransport transport = new TSocket(host, port, timeoutMillis); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); return new ThriftHiveMetastore.Client(protocol); }
@Override public TableMetadata refresh() { String metadataLocation = null; try { final Table table = metaStoreClient.get_table(database, tableName); String tableType = table.getParameters().get(TABLE_TYPE_PROP); if (tableType == null || !tableType.equalsIgnoreCase(ICEBERG_TABLE_TYPE_VALUE)) { throw new IllegalArgumentException(format("Invalid tableName, not Iceberg: %s.%s", database, table)); } metadataLocation = table.getParameters().get(METADATA_LOCATION_PROP); if (metadataLocation == null) { throw new IllegalArgumentException(format("%s.%s is missing %s property", database, tableName, METADATA_LOCATION_PROP)); } } catch (NoSuchObjectException e) { if (currentMetadataLocation() != null) { throw new NoSuchTableException(format("No such table: %s.%s", database, tableName)); } } catch (TException e) { throw new RuntimeException(format("Failed to get table info from metastore %s.%s", database, tableName)); } refreshFromMetadataLocation(metadataLocation); return current(); }
void setStatistics(TableName tableName, TableStatistics tableStatistics) { try { Table table = client.get_table(getSchema(tableName), tableName.getSchemalessNameInDatabase()); setRowsCount(tableName, tableStatistics, table); try { setColumnStatistics(tableName, tableStatistics, table, fieldSchema -> true); } catch (TException ignore) { transport.close(); transport.open(); // try to avoid date type as it not supported in hive 1.1.0 setColumnStatistics(tableName, tableStatistics, table, fieldSchema -> !fieldSchema.getType().equals("date")); } } catch (TException e) { throw new RuntimeException(e); } }
/** * TODO. * * @param dbName TODO * @param tableName TODO * @return TODO * * @throws HiveMetastoreException TODO */ public synchronized Table getTable(String dbName, String tableName) throws HiveMetastoreException { try { connectIfNeeded(); return client.get_table(dbName, tableName); } catch (NoSuchObjectException e) { return null; } catch (TException e) { close(); throw new HiveMetastoreException(e); } }
/** * TODO. * * @param dbName TODO * @param tableName TODO * @param deleteData TODO * * @throws HiveMetastoreException TODO */ public synchronized void dropTable(String dbName, String tableName, boolean deleteData) throws HiveMetastoreException { try { connectIfNeeded(); client.drop_table(dbName, tableName, deleteData); } catch (TException e) { close(); throw new HiveMetastoreException(e); } }
/** * TODO. * * @param dbName TODO * @param tableName TODO * @param table TODO * * @throws HiveMetastoreException TODO */ public synchronized void alterTable(String dbName, String tableName, Table table) throws HiveMetastoreException { try { connectIfNeeded(); client.alter_table(dbName, tableName, table); } catch (TException e) { close(); throw new HiveMetastoreException(e); } }
/** * TODO. * * @param dbName TODO * @param tableName TODO * @param table TODO * * @throws HiveMetastoreException TODO */ public synchronized void alterTable(String dbName, String tableName, Table table) throws HiveMetastoreException { try { connectIfNeeded(); client.alter_table(dbName, tableName, table); } catch (TException e) { close(); throw new HiveMetastoreException(e); } }
/** * TODO. * * @param dbName TODO * @param tableName TODO * @param deleteData TODO * * @throws HiveMetastoreException TODO */ public synchronized void dropTable(String dbName, String tableName, boolean deleteData) throws HiveMetastoreException { try { connectIfNeeded(); client.drop_table(dbName, tableName, deleteData); } catch (TException e) { close(); throw new HiveMetastoreException(e); } }
void setStatistics(TableName tableName, TableStatistics tableStatistics) { try { Table table = client.get_table(getSchema(tableName), tableName.getSchemalessNameInDatabase()); setRowsCount(tableName, tableStatistics, table); try { setColumnStatistics(tableName, tableStatistics, table, fieldSchema -> true); } catch (TException ignore) { transport.close(); transport.open(); // try to avoid date type as it not supported in hive 1.1.0 setColumnStatistics(tableName, tableStatistics, table, fieldSchema -> !fieldSchema.getType().equals("date")); } } catch (TException e) { throw new RuntimeException(e); } }
/** * TODO. * * @param table TODO * * @throws HiveMetastoreException TODO */ public synchronized void createTable(Table table) throws HiveMetastoreException { try { connectIfNeeded(); client.create_table(table); } catch (TException e) { close(); throw new HiveMetastoreException(e); } }
/** * TODO. * * @param table TODO * * @throws HiveMetastoreException TODO */ public synchronized void createTable(Table table) throws HiveMetastoreException { try { connectIfNeeded(); client.create_table(table); } catch (TException e) { close(); throw new HiveMetastoreException(e); } }
/** * TODO. * * @throws HiveMetastoreException TODO */ private void connect() throws HiveMetastoreException { LOG.info("Connecting to ThriftHiveMetastore " + host + ":" + port); transport = new TSocket(host, port, 1000 * clientSocketTimeout); this.client = new ThriftHiveMetastore.Client(new TBinaryProtocol(transport)); try { transport.open(); } catch (TTransportException e) { close(); throw new HiveMetastoreException(e); } }
/** * TODO. * * @throws HiveMetastoreException TODO */ private void connect() throws HiveMetastoreException { LOG.info("Connecting to ThriftHiveMetastore " + host + ":" + port); transport = new TSocket(host, port, 1000 * clientSocketTimeout); this.client = new ThriftHiveMetastore.Client(new TBinaryProtocol(transport)); try { transport.open(); } catch (TTransportException e) { close(); throw new HiveMetastoreException(e); } }