/** * This method creates the Upsert statement and the Column Metadata * for the Pig query using {@link PhoenixHBaseStorage}. It also * determines the batch size based on user provided options. * * @param conn * @throws SQLException */ public void setup(Connection conn) throws SQLException { // Reset batch size long batchSize = getBatchSize() <= 0 ? ((PhoenixConnection) conn).getMutateBatchSize() : getBatchSize(); conf.setLong(UPSERT_BATCH_SIZE, batchSize); if (columnMetadataList == null) { columnMetadataList = new ArrayList<ColumnInfo>(); String[] tableMetadata = getTableMetadata(getTableName()); ResultSet rs = conn.getMetaData().getColumns(null, tableMetadata[0], tableMetadata[1], null); while (rs.next()) { columnMetadataList.add(new ColumnInfo(rs.getString(QueryUtil.COLUMN_NAME_POSITION), rs.getInt(QueryUtil.DATA_TYPE_POSITION))); } } // Generating UPSERT statement without column name information. String upsertStmt = QueryUtil.constructUpsertStatement(null, getTableName(), columnMetadataList.size()); LOG.info("Phoenix Upsert Statement: " + upsertStmt); conf.set(UPSERT_STATEMENT, upsertStmt); }
this.upsertStatement = QueryUtil.constructUpsertStatement(columnMetadata, fullTableName, columnMetadata.length); logger.info(" the upsert statement is {} " ,this.upsertStatement);
stmtCache = new PreparedStatement[columnInfo.length]; } else { String upsertStatement = QueryUtil.constructUpsertStatement(columnInfo, tableName, columnInfo.length - unfoundColumnCount); stmt = conn.prepareStatement(upsertStatement); stmt = stmtCache[nextLine.length-1]; if (stmt == null) { String upsertStatement = QueryUtil.constructUpsertStatement(columnInfo, tableName, nextLine.length); stmt = conn.prepareStatement(upsertStatement); stmtCache[nextLine.length-1] = stmt;