@Override public List<Column> getColumns() { return aliasedTable.getColumns(); }
@Override public FilterBuilder<RowUpdationBuilder> where(String columnName) { Column column = _table.getColumnByName(columnName); if (column == null) { throw new IllegalArgumentException("No such column: " + columnName); } return where(column); }
protected ImmutableTable(Table table, ImmutableSchema schema) { this(table.getName(), table.getType(), schema, table.getRemarks(), table.getQuote()); List<Column> origColumns = table.getColumns(); for (Column column : origColumns) { columns.add(new ImmutableColumn(column, this)); } }
public Schema toSerializableForm() { for (Table table : getTables()) { table.getColumns(); table.getIndexedColumns(); table.getPrimaryKeys(); } loadRelations(); return this; }
@Override protected String getBannerTitle() { return "Save " + _table.getName() + "\nas Excel spreadsheet file"; } };
private void loadIndexes(Table table, DatabaseMetaData metaData) throws MetaModelException { Schema schema = table.getSchema(); // Ticket #170: IndexInfo is nice-to-have, not need-to-have, so // we will do a nice failover on SQLExceptions try (ResultSet rs = metaData.getIndexInfo(getCatalogName(schema), getJdbcSchemaName(schema), table.getName(), false, true)) { while (rs.next()) { String columnName = rs.getString(9); if (columnName != null) { MutableColumn column = (MutableColumn) table.getColumnByName(columnName); if (column != null) { column.setIndexed(true); } else { logger.error("Indexed column \"{}\" could not be found in table: {}", columnName, table); } } } } catch (SQLException e) { throw JdbcUtils.wrapException(e, "retrieve index information for " + table.getName(), JdbcActionType.METADATA); } }
Column[] primaryKeyColumns = _table.getPrimaryKeys(); if (primaryKeyColumns == null || primaryKeyColumns.length == 0) { logger.info("No primary keys defined for table {}, not pre-selecting primary keys", _table.getName()); return;
private SimpleTableDef createTableDef(final Table table) { final int columnCount = table.getColumnCount(); final String[] names = new String[columnCount]; final ColumnType[] types = new ColumnType[columnCount]; for (int i = 0; i < columnCount; i++) { names[i] = table.getColumn(i).getName(); types[i] = table.getColumn(i).getType(); } return new SimpleTableDef(table.getName(), names, types); }
protected boolean isMainSchemaTable(Table table) { Schema schema = table.getSchema(); if (INFORMATION_SCHEMA_NAME.equals(schema.getName())) { return false; } else { return true; } }
@Override protected void writeHeader(final Writer writer) throws IOException { final List<String> headers = new ArrayList<>(table.getColumnNames()); if (!_isColumnToBeSortedOnPresentInInput) { headers.remove(columnToBeSortedOn.getName()); } final String[] columnNames = headers.toArray(new String[0]); final String line = csvWriter.buildLine(columnNames); writer.write(line); }
@Override public TableMetadata getTableMetadata(Table table) { if (table == null) { return null; } final String tableName = table.getName(); return getTableMetadataByName(tableName); }
protected ImmutableTable(Table table, ImmutableSchema schema) { this(table.getName(), table.getType(), schema, table.getRemarks(), table.getQuote()); List<Column> origColumns = table.getColumns(); for (Column column : origColumns) { columns.add(new ImmutableColumn(column, this)); } }
private void loadIndexes(Table table, DatabaseMetaData metaData) throws MetaModelException { Schema schema = table.getSchema(); // Ticket #170: IndexInfo is nice-to-have, not need-to-have, so // we will do a nice failover on SQLExceptions try (ResultSet rs = metaData.getIndexInfo(getCatalogName(schema), getJdbcSchemaName(schema), table.getName(), false, true)) { while (rs.next()) { String columnName = rs.getString(9); if (columnName != null) { MutableColumn column = (MutableColumn) table.getColumnByName(columnName); if (column != null) { column.setIndexed(true); } else { logger.error("Indexed column \"{}\" could not be found in table: {}", columnName, table); } } } } catch (SQLException e) { throw JdbcUtils.wrapException(e, "retrieve index information for " + table.getName(), JdbcActionType.METADATA); } }
/** * Inspects the row processed tables primary keys. If all primary keys are * in the source columns of the AnalysisJob, they will be added to the * physically queried columns. * * Adding the primary keys to the query is a trade-off: It helps a lot in * making eg. annotated rows referenceable to the source table, but it may * also potentially make the job heavier to execute since a lot of (unique) * values will be retrieved. */ public void addPrimaryKeysIfSourced() { final List<Column> primaryKeyColumns = getTable().getPrimaryKeys(); if (primaryKeyColumns == null || primaryKeyColumns.isEmpty()) { logger.info("No primary keys defined for table {}, not pre-selecting primary keys", getTable().getName()); return; } final Collection<InputColumn<?>> sourceInputColumns = getAnalysisJob().getSourceColumns(); final List<Column> sourceColumns = CollectionUtils.map(sourceInputColumns, InputColumn::getPhysicalColumn); for (final Column primaryKeyColumn : primaryKeyColumns) { if (!sourceColumns.contains(primaryKeyColumn)) { logger.info("Primary key column {} not added to source columns, not pre-selecting primary keys"); return; } } addPhysicalColumns(primaryKeyColumns); }
protected boolean isMainSchemaTable(Table table) { Schema schema = table.getSchema(); if (INFORMATION_SCHEMA_NAME.equals(schema.getName())) { return false; } else { return true; } }
public Schema toSerializableForm() { for (Table table : getTables()) { table.getColumns(); table.getIndexedColumns(); table.getPrimaryKeys(); } loadRelations(); return this; }
@Override protected void writeHeader(final ExcelDataContextWriter writer) throws IOException { final List<String> headers = new ArrayList<>(table.getColumnNames()); if (!isColumnToBeSortedOnPresentInInput) { headers.remove(columnToBeSortedOn.getName()); } writer.createTable(headers); }
@Override public String toString() { return getTable().getName(); } }