@Override public IndexedRecord getCurrent() throws NoSuchElementException { try { return factory.convertToAvro(resultSet); } catch (Exception e) { throw new ComponentException(e); } }
@Override public void setSchema(Schema schema) { this.schema = schema; names = new String[getSchema().getFields().size()]; fieldConverter = new AvroConverter[names.length]; for (int j = 0; j < names.length; j++) { Field f = getSchema().getFields().get(j); names[j] = f.name(); JDBCAvroRegistry.JDBCConverter jdbcConverter = getRegistry().getConverter(f); if (influencer != null) { jdbcConverter.setInfluencer(influencer); } fieldConverter[j] = jdbcConverter; } }
@Override public ValidationResult initialize(RuntimeContainer runtime, ComponentProperties properties) { this.properties = (RuntimeSettingProvider) properties; setting = this.properties.getRuntimeSetting(); converter = new JDBCResultSetIndexedRecordConverter(); ((JDBCResultSetIndexedRecordConverter) converter).setInfluencer(setting); return ValidationResult.OK; }
resultSetFactory.setSchema(mainSchema); IndexedRecord resultSetIndexedRecord = resultSetFactory.convertToAvro(rs);
@Override public boolean start() throws IOException { if (null == factory.getSchema()) { factory.setSchema(getSchema()); } result = new Result(); try { statement = getConnection().createStatement(); resultSet = statement.executeQuery(getQueryString()); return haveNext(); } catch (Exception e) { throw new IOException(i18nMessages.getMessage("error.processQuery", getQueryString()), e); } }
@Override public Schema getSchema() { return JDBCResultSetIndexedRecordConverter.this.getSchema(); }
private IndexedRecordConverter<ResultSet, IndexedRecord> getConverter(ResultSet resultSet) throws IOException, SQLException { if (converter == null) { converter = source.getConverter(); // this is need to be called before setSchema if (converter instanceof JDBCResultSetIndexedRecordConverter) { ((JDBCResultSetIndexedRecordConverter) converter).setInfluencer(setting); } converter.setSchema(getSchema()); int sizeInResultSet = resultSet.getMetaData().getColumnCount(); if (converter instanceof JDBCResultSetIndexedRecordConverter) { ((JDBCResultSetIndexedRecordConverter) converter).setSizeInResultSet(sizeInResultSet); } } return converter; }
@Override public boolean start() throws IOException { connection = source.createConnection(container); result = new Result(); Schema schema = source.getRuntimeSchema(container); schemaReject = properties.schemaReject.schema.getValue(); converter.setSchema(schema); this.dieOnError = properties.dieOnError.getValue(); try { if (source.usePreparedStatement()) { statement = connection.prepareStatement(source.getQuery()); PreparedStatement pstmt = (PreparedStatement) statement; SnowflakePreparedStatementUtils.fillPreparedStatement(pstmt, properties.preparedStatementTable); pstmt.execute(); rs = pstmt.getResultSet(); pstmt.clearParameters(); } else { statement = connection.createStatement(); rs = statement.executeQuery(source.getQuery()); } } catch (SQLException e) { if (dieOnError) { throw new IOException(e); } LOGGER.warn(I18N_MESSAGES.getMessage("error.queryExecution"), e); handleReject(e); } return advance(); }
public ResultSetIndexedRecord(ResultSet resultSet) { resetSizeByResultSet(resultSet); values = new Object[names.length]; for (int i = 0; i < values.length; i++) { if ((sizeInResultSet > 0) && (i == sizeInResultSet)) { break; } values[i] = fieldConverter[i].convertToAvro(resultSet); } }
resultSetFactory.setSchema(mainSchema); IndexedRecord resultSetIndexedRecord = resultSetFactory.convertToAvro(rs);
@Override public Schema getSchema() { return JDBCResultSetIndexedRecordConverter.this.getSchema(); }
private IndexedRecordConverter<ResultSet, IndexedRecord> getConverter(ResultSet resultSet) throws IOException, SQLException { if (converter == null) { converter = source.getConverter(); // this is need to be called before setSchema if (converter instanceof JDBCResultSetIndexedRecordConverter) { ((JDBCResultSetIndexedRecordConverter) converter).setInfluencer(setting); } converter.setSchema(getSchema()); int sizeInResultSet = resultSet.getMetaData().getColumnCount(); if (converter instanceof JDBCResultSetIndexedRecordConverter) { ((JDBCResultSetIndexedRecordConverter) converter).setSizeInResultSet(sizeInResultSet); } } return converter; }
public ResultSetIndexedRecord(ResultSet resultSet) { resetSizeByResultSet(resultSet); values = new Object[names.length]; for (int i = 0; i < values.length; i++) { if ((sizeInResultSet > 0) && (i == sizeInResultSet)) { break; } values[i] = fieldConverter[i].convertToAvro(resultSet); } }
resultSetFactory.setSchema(mainSchema); IndexedRecord resultSetIndexedRecord = resultSetFactory.convertToAvro(rs);
@Override public void setSchema(Schema schema) { this.schema = schema; names = new String[getSchema().getFields().size()]; fieldConverter = new AvroConverter[names.length]; for (int j = 0; j < names.length; j++) { Field f = getSchema().getFields().get(j); names[j] = f.name(); JDBCAvroRegistry.JDBCConverter jdbcConverter = getRegistry().getConverter(f); if (influencer != null) { jdbcConverter.setInfluencer(influencer); } fieldConverter[j] = jdbcConverter; } }
@Override public ValidationResult initialize(RuntimeContainer runtime, ComponentProperties properties) { this.properties = (RuntimeSettingProvider) properties; setting = this.properties.getRuntimeSetting(); converter = new JDBCResultSetIndexedRecordConverter(); ((JDBCResultSetIndexedRecordConverter) converter).setInfluencer(setting); return ValidationResult.OK; }
@Override public boolean advance() throws IOException { if (isRejectError) { // if advance returns false, we can't enter getCurrent() for throwing DataRejectException. return true; } boolean validationResult = validateResultSet(rs); if (!validationResult) { return false; } boolean hasNext = false; try { hasNext = rs.next(); } catch (SQLException e) { if (dieOnError) { throw new IOException(e); } LOGGER.warn(I18N_MESSAGES.getMessage("error.resultSetIssue"), e); } if (hasNext) { current = converter.convertToAvro(rs); result.totalCount++; result.successCount++; } return hasNext; }