@Override public String[] getFieldNames() { return schema.getFieldNames(); }
@Override public String[] getFieldNames() { return schema.getFieldNames(); }
/** * @deprecated Use {@link TableSchema#getFieldNames()} instead. Can be dropped after 1.7. */ @Deprecated public String[] getColumnNames() { return getFieldNames(); }
@Override public String explainSource() { return TableConnectorUtil.generateRuntimeName(this.getClass(), schema.getFieldNames()); }
private boolean checkForCustomFieldMapping(DescriptorProperties descriptorProperties, TableSchema schema) { final Map<String, String> fieldMapping = SchemaValidator.deriveFieldMapping( descriptorProperties, Optional.of(schema.toRowType())); // until FLINK-9870 is fixed we assume that the table schema is the output type return fieldMapping.size() != schema.getFieldNames().length || !fieldMapping.entrySet().stream().allMatch(mapping -> mapping.getKey().equals(mapping.getValue())); }
/** * Adds a table schema under the given key. */ public void putTableSchema(String key, TableSchema schema) { checkNotNull(key); checkNotNull(schema); final String[] fieldNames = schema.getFieldNames(); final TypeInformation<?>[] fieldTypes = schema.getFieldTypes(); final List<List<String>> values = new ArrayList<>(); for (int i = 0; i < schema.getFieldCount(); i++) { values.add(Arrays.asList(fieldNames[i], TypeStringUtils.writeTypeInfo(fieldTypes[i]))); } putIndexedFixedProperties( key, Arrays.asList(TABLE_SCHEMA_NAME, TABLE_SCHEMA_TYPE), values); }
@Override protected List<AttributedString> computeMainHeaderLines() { final AttributedStringBuilder schemaHeader = new AttributedStringBuilder(); Arrays.stream(resultDescriptor.getResultSchema().getFieldNames()).forEach(s -> { schemaHeader.append(' '); schemaHeader.style(AttributedStyle.DEFAULT.underline()); normalizeColumn(schemaHeader, s, MAX_COLUMN_WIDTH); schemaHeader.style(AttributedStyle.DEFAULT); }); return Collections.singletonList(schemaHeader.toAttributedString()); }
protected void openRow() { if (selectedRow == NO_ROW_SELECTED) { return; } final CliRowView view = new CliRowView( client, resultDescriptor.getResultSchema().getFieldNames(), CliUtils.typesToString(resultDescriptor.getResultSchema().getFieldTypes()), getRow(results.get(selectedRow))); view.open(); // enter view }
@Override protected List<AttributedString> computeMainHeaderLines() { final AttributedStringBuilder schemaHeader = new AttributedStringBuilder(); // add change column schemaHeader.append(' '); schemaHeader.style(AttributedStyle.DEFAULT.underline()); schemaHeader.append("+/-"); schemaHeader.style(AttributedStyle.DEFAULT); Arrays.stream(resultDescriptor.getResultSchema().getFieldNames()).forEach(s -> { schemaHeader.append(' '); schemaHeader.style(AttributedStyle.DEFAULT.underline()); normalizeColumn(schemaHeader, s, MAX_COLUMN_WIDTH); schemaHeader.style(AttributedStyle.DEFAULT); }); return Collections.singletonList(schemaHeader.toAttributedString()); }
private static TableSchema removeTimeAttributes(TableSchema schema) { final TableSchema.Builder builder = TableSchema.builder(); for (int i = 0; i < schema.getFieldCount(); i++) { final TypeInformation<?> type = schema.getFieldTypes()[i]; final TypeInformation<?> convertedType; if (FlinkTypeFactory.isTimeIndicatorType(type)) { convertedType = Types.SQL_TIMESTAMP; } else { convertedType = type; } builder.field(schema.getFieldNames()[i], convertedType); } return builder.build(); } }
final String fieldName = baseSchema.getFieldNames()[i]; final TypeInformation<?> fieldType = baseSchema.getFieldTypes()[i];
/** * Creates a result. Might start threads or opens sockets so every created result must be closed. */ public <T> DynamicResult<T> createResult(Environment env, TableSchema schema, ExecutionConfig config) { final TypeInformation<Row> outputType = Types.ROW_NAMED(schema.getFieldNames(), schema.getFieldTypes()); if (env.getExecution().isStreamingExecution()) { // determine gateway address (and port if possible) final InetAddress gatewayAddress = getGatewayAddress(env.getDeployment()); final int gatewayPort = getGatewayPort(env.getDeployment()); if (env.getExecution().isChangelogMode()) { return new ChangelogCollectStreamResult<>(outputType, config, gatewayAddress, gatewayPort); } else { return new MaterializedCollectStreamResult<>( outputType, config, gatewayAddress, gatewayPort, env.getExecution().getMaxTableResultRows()); } } else { // Batch Execution if (!env.getExecution().isTableMode()) { throw new SqlExecutionException("Results of batch queries can only be served in table mode."); } return new MaterializedCollectBatchResult<>(outputType, config); } }
@Override public String[] getFieldNames() { return schema.getFieldNames(); }
/** * @deprecated Use {@link TableSchema#getFieldNames()} instead. Can be dropped after 1.7. */ @Deprecated public String[] getColumnNames() { return getFieldNames(); }
private void checkPartitionKeys(TableSchema schema, LinkedHashSet<String> partitionColumnNames) { if (!partitionColumnNames.isEmpty()) { String[] colNames = schema.getFieldNames(); String[] expectedPartitionCols = Arrays.copyOfRange(colNames, colNames.length - partitionColumnNames.size(), colNames.length); String[] partitionCols = new String[partitionColumnNames.size()]; partitionColumnNames.toArray(partitionCols); if (!Arrays.equals(expectedPartitionCols, partitionCols)) { throw new IllegalArgumentException( String.format("Partition columns %s does not match the last %d columns of TableSchema %s", partitionColumnNames, partitionColumnNames.size(), tableSchema.getFieldNames()) ); } } }
@Override public String explainSource() { return TableConnectorUtil.generateRuntimeName(this.getClass(), schema.getFieldNames()); }
@Override public String explainSource() { return TableConnectorUtil.generateRuntimeName(this.getClass(), schema.getFieldNames()); }
private boolean checkForCustomFieldMapping(DescriptorProperties descriptorProperties, TableSchema schema) { final Map<String, String> fieldMapping = SchemaValidator.deriveFieldMapping( descriptorProperties, Optional.of(schema.toRowType())); // until FLINK-9870 is fixed we assume that the table schema is the output type return fieldMapping.size() != schema.getFieldNames().length || !fieldMapping.entrySet().stream().allMatch(mapping -> mapping.getKey().equals(mapping.getValue())); }
private boolean checkForCustomFieldMapping(DescriptorProperties descriptorProperties, TableSchema schema) { final Map<String, String> fieldMapping = SchemaValidator.deriveFieldMapping( descriptorProperties, Optional.of(schema.toRowType())); // until FLINK-9870 is fixed we assume that the table schema is the output type return fieldMapping.size() != schema.getFieldNames().length || !fieldMapping.entrySet().stream().allMatch(mapping -> mapping.getKey().equals(mapping.getValue())); }
public CatalogTable( String tableType, TableSchema tableSchema, TableStats tableStats, Map<String, String> properties, boolean isStreaming) { this.tableType = tableType; this.tableSchema = tableSchema; this.tableStats = tableStats; this.properties = properties; this.isStreaming = isStreaming; this.richTableSchema = new RichTableSchema(tableSchema.getFieldNames(), tableSchema.getFieldTypes()); }