/** * Creates a builder for defining attributes. * * @param dbName the db name * @param tableName the table name * @param columns the columns * @return the builder */ @Deprecated // @deprecated in favour of {@link #create(HCatTable)}. To be removed in Hive 0.16. public static Builder create(String dbName, String tableName, List<HCatFieldSchema> columns) { return new Builder(dbName, tableName, columns); }
/** * See <i>row_format</i> element of CREATE_TABLE DDL for Hive. */ @Deprecated // @deprecated in favour of {@link HCatTable.#nullDefinedAs()}. To be removed in Hive 0.16. public Builder nullDefinedAs(char nullChar) { return serdeParam(serdeConstants.SERIALIZATION_NULL_FORMAT, Character.toString(nullChar)); } /**
try { HCatCreateTableDesc tableDesc = HCatCreateTableDesc .create(null, tableName, cols).fileFormat("rcfile").build(); client.createTable(tableDesc); } catch (Exception exp) { client.dropTable(null, newName, true); HCatCreateTableDesc tableDesc2 = HCatCreateTableDesc .create(null, newName, cols).fileFormat("rcfile").build(); client.createTable(tableDesc2); HCatTable newTable = client.getTable(null, newName);
public void createTable(String db, String table, String partitionCols) throws Exception { List<HCatFieldSchema> cols = new ArrayList<HCatFieldSchema>(); cols.add(new HCatFieldSchema("userid", Type.INT, "userid")); cols.add(new HCatFieldSchema("viewtime", Type.BIGINT, "view time")); cols.add(new HCatFieldSchema("pageurl", Type.STRING, "page url visited")); cols.add(new HCatFieldSchema("ip", Type.STRING, "IP Address of the User")); ArrayList<HCatFieldSchema> ptnCols = new ArrayList<HCatFieldSchema>(); for (String partitionCol : partitionCols.split(",")) { ptnCols.add(new HCatFieldSchema(partitionCol, Type.STRING, null)); } // Remove this once NotificationListener is fixed and available in HCat snapshot Map<String, String> tblProps = new HashMap<String, String>(); tblProps.put(HCatConstants.HCAT_MSGBUS_TOPIC_NAME, "hcat." + db + "." + table); HCatCreateTableDesc tableDesc = HCatCreateTableDesc.create(db, table, cols).fileFormat("textfile") .partCols(ptnCols).tblProps(tblProps ).build(); hcatClient.createTable(tableDesc); List<String> tables = hcatClient.listTableNamesByPattern(db, "*"); assertTrue(tables.contains(table)); }
public void createTable(String db, String table) throws Exception { List<HCatFieldSchema> cols = new ArrayList<HCatFieldSchema>(); cols.add(new HCatFieldSchema("userid", Type.INT, "userid")); cols.add(new HCatFieldSchema("viewtime", Type.BIGINT, "view time")); cols.add(new HCatFieldSchema("pageurl", Type.STRING, "page url visited")); cols.add(new HCatFieldSchema("ip", Type.STRING, "IP Address of the User")); // Remove this once NotificationListener is fixed and available in HCat snapshot Map<String, String> tblProps = new HashMap<String, String>(); tblProps.put(HCatConstants.HCAT_MSGBUS_TOPIC_NAME, "hcat." + db + "." + table); HCatCreateTableDesc tableDesc = HCatCreateTableDesc.create(db, table, cols).fileFormat("textfile") .tblProps(tblProps ).build(); hcatClient.createTable(tableDesc); List<String> tables = hcatClient.listTableNamesByPattern(db, "*"); assertTrue(tables.contains(table)); }
/** * Getter for HCatCreateTableDesc.Builder instance. By default, ifNotExists is false. * So the attempt to create the table is made even if the table already exists. * @param table Spec for HCatTable to be created. * @return Builder instance. */ public static Builder create(HCatTable table) { return new Builder(table, false); }
/** * Creates a builder for defining attributes. * * @param dbName the db name * @param tableName the table name * @param columns the columns * @return the builder */ @Deprecated // @deprecated in favour of {@link #create(HCatTable)}. To be removed in Hive 0.16. public static Builder create(String dbName, String tableName, List<HCatFieldSchema> columns) { return new Builder(dbName, tableName, columns); }
/** * See <i>row_format</i> element of CREATE_TABLE DDL for Hive. */ @Deprecated // @deprecated in favour of {@link HCatTable.#mapKeysTerminatedBy()}. To be removed in Hive 0.16. public Builder mapKeysTerminatedBy(char delimiter) { return serdeParam(serdeConstants.MAPKEY_DELIM, Character.toString(delimiter)); } /**
/** * See <i>row_format</i> element of CREATE_TABLE DDL for Hive. */ @Deprecated // @deprecated in favour of {@link HCatTable.#collectionItemsTerminatedBy()}. To be removed in Hive 0.16. public Builder collectionItemsTerminatedBy(char delimiter) { return serdeParam(serdeConstants.COLLECTION_DELIM, Character.toString(delimiter)); } /**
/** * Getter for HCatCreateTableDesc.Builder instance. * @param table Spec for HCatTable to be created. * @param ifNotExists Only create the table if it doesn't already exist. * @return Builder instance. */ public static Builder create(HCatTable table, boolean ifNotExists) { return new Builder(table, ifNotExists); }
/** * Creates a builder for defining attributes. * * @param dbName the db name * @param tableName the table name * @param columns the columns * @return the builder */ @Deprecated // @deprecated in favour of {@link #create(HCatTable)}. To be removed in Hive 0.16. public static Builder create(String dbName, String tableName, List<HCatFieldSchema> columns) { return new Builder(dbName, tableName, columns); }
/** * See <i>row_format</i> element of CREATE_TABLE DDL for Hive. */ @Deprecated // @deprecated in favour of {@link HCatTable.#nullDefinedAs()}. To be removed in Hive 0.16. public Builder nullDefinedAs(char nullChar) { return serdeParam(serdeConstants.SERIALIZATION_NULL_FORMAT, Character.toString(nullChar)); } /**
/** * See <i>row_format</i> element of CREATE_TABLE DDL for Hive. */ @Deprecated // @deprecated in favour of {@link HCatTable.#escapeChar()}. public Builder escapeChar(char escapeChar) { return serdeParam(serdeConstants.ESCAPE_CHAR, Character.toString(escapeChar)); } /**
/** * See <i>row_format</i> element of CREATE_TABLE DDL for Hive. */ @Deprecated // @deprecated in favour of {@link HCatTable.#fieldsTerminatedBy()}. To be removed in Hive 0.16. public Builder fieldsTerminatedBy(char delimiter) { return serdeParam(serdeConstants.FIELD_DELIM, Character.toString(delimiter)); } /**
/** * See <i>row_format</i> element of CREATE_TABLE DDL for Hive. */ @Deprecated // @deprecated in favour of {@link HCatTable.#mapKeysTerminatedBy()}. To be removed in Hive 0.16. public Builder mapKeysTerminatedBy(char delimiter) { return serdeParam(serdeConstants.MAPKEY_DELIM, Character.toString(delimiter)); } /**
/** * See <i>row_format</i> element of CREATE_TABLE DDL for Hive. */ @Deprecated // @deprecated in favour of {@link HCatTable.#fieldsTerminatedBy()}. To be removed in Hive 0.16. public Builder fieldsTerminatedBy(char delimiter) { return serdeParam(serdeConstants.FIELD_DELIM, Character.toString(delimiter)); } /**
/** * Getter for HCatCreateTableDesc.Builder instance. By default, ifNotExists is false. * So the attempt to create the table is made even if the table already exists. * @param table Spec for HCatTable to be created. * @return Builder instance. */ public static Builder create(HCatTable table) { return new Builder(table, false); }
/** * See <i>row_format</i> element of CREATE_TABLE DDL for Hive. */ @Deprecated // @deprecated in favour of {@link HCatTable.#linesTerminatedBy()}. To be removed in Hive 0.16. public Builder linesTerminatedBy(char delimiter) { return serdeParam(serdeConstants.LINE_DELIM, Character.toString(delimiter)); } /**
/** * Getter for HCatCreateTableDesc.Builder instance. By default, ifNotExists is false. * So the attempt to create the table is made even if the table already exists. * @param table Spec for HCatTable to be created. * @return Builder instance. */ public static Builder create(HCatTable table) { return new Builder(table, false); }
/** * Getter for HCatCreateTableDesc.Builder instance. * @param table Spec for HCatTable to be created. * @param ifNotExists Only create the table if it doesn't already exist. * @return Builder instance. */ public static Builder create(HCatTable table, boolean ifNotExists) { return new Builder(table, ifNotExists); }