/** * Converts a table schema into a (nested) type information describing a {@link Row}. */ public TypeInformation<Row> toRowType() { return Types.ROW_NAMED(fieldNames, fieldTypes); }
@Override public TypeInformation<Row> getOutputType() { return Types.ROW_NAMED(fieldNames, fieldTypes); }
@Override public TypeInformation<Row> getRecordType() { return Types.ROW_NAMED(fieldNames, fieldTypes); }
names[i] = field.name(); return Types.ROW_NAMED(names, types); case ENUM: return Types.STRING;
private static TypeInformation<Row> convertObject(String location, JsonNode node, JsonNode root) { // validate properties if (!node.has(PROPERTIES)) { return Types.ROW(); } if (!node.isObject()) { throw new IllegalArgumentException( "Invalid '" + PROPERTIES + "' property for object type in node: " + location); } final JsonNode props = node.get(PROPERTIES); final String[] names = new String[props.size()]; final TypeInformation<?>[] types = new TypeInformation[props.size()]; final Iterator<Map.Entry<String, JsonNode>> fieldIter = props.fields(); int i = 0; while (fieldIter.hasNext()) { final Map.Entry<String, JsonNode> subNode = fieldIter.next(); // set field name names[i] = subNode.getKey(); // set type types[i] = convertType(location + '/' + subNode.getKey(), subNode.getValue(), root); i++; } // validate that object does not contain additional properties if (node.has(ADDITIONAL_PROPERTIES) && node.get(ADDITIONAL_PROPERTIES).isBoolean() && node.get(ADDITIONAL_PROPERTIES).asBoolean()) { throw new IllegalArgumentException( "An object must not allow additional properties in node: " + location); } return Types.ROW_NAMED(names, types); }
return Types.ROW_NAMED( names.toArray(new String[0]), types.toArray(new TypeInformation<?>[0]));
Types.ROW_NAMED( new String[]{"hello", "world"}, Types.BIG_DEC, Types.BYTE)); Types.ROW_NAMED( new String[] {"he \nllo", "world"}, Types.BIG_DEC, Types.BYTE), Types.ROW_NAMED( new String[] {"he`llo", "world"}, Types.BIG_DEC, Types.BYTE), Types.ROW_NAMED( new String[] {"he \nllo", "world"}, Types.BIG_DEC, Types.BYTE), Types.ROW_NAMED( new String[] {"singleton", "twoField"}, Types.ROW(Types.INT), Types.ROW_NAMED( new String[] {"Field 1", "Field`s 2"}, Types.ROW(Types.BIG_DEC), Types.STRING)));
/** * 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); } }
/** * Converts a table schema into a (nested) type information describing a {@link Row}. */ public TypeInformation<Row> toRowType() { return Types.ROW_NAMED(fieldNames, fieldTypes); }
names[i] = field.name(); return Types.ROW_NAMED(names, types); case ENUM: return Types.STRING;
names[i] = field.name(); return Types.ROW_NAMED(names, types); case ENUM: return Types.STRING;
private static TypeInformation<Row> convertObject(String location, JsonNode node, JsonNode root) { // validate properties if (!node.has(PROPERTIES)) { return Types.ROW(); } if (!node.isObject()) { throw new IllegalArgumentException( "Invalid '" + PROPERTIES + "' property for object type in node: " + location); } final JsonNode props = node.get(PROPERTIES); final String[] names = new String[props.size()]; final TypeInformation<?>[] types = new TypeInformation[props.size()]; final Iterator<Map.Entry<String, JsonNode>> fieldIter = props.fields(); int i = 0; while (fieldIter.hasNext()) { final Map.Entry<String, JsonNode> subNode = fieldIter.next(); // set field name names[i] = subNode.getKey(); // set type types[i] = convertType(location + '/' + subNode.getKey(), subNode.getValue(), root); i++; } // validate that object does not contain additional properties if (node.has(ADDITIONAL_PROPERTIES) && node.get(ADDITIONAL_PROPERTIES).isBoolean() && node.get(ADDITIONAL_PROPERTIES).asBoolean()) { throw new IllegalArgumentException( "An object must not allow additional properties in node: " + location); } return Types.ROW_NAMED(names, types); }
private static TypeInformation<Row> convertObject(String location, JsonNode node, JsonNode root) { // validate properties if (!node.has(PROPERTIES)) { return Types.ROW(); } if (!node.isObject()) { throw new IllegalArgumentException( "Invalid '" + PROPERTIES + "' property for object type in node: " + location); } final JsonNode props = node.get(PROPERTIES); final String[] names = new String[props.size()]; final TypeInformation<?>[] types = new TypeInformation[props.size()]; final Iterator<Map.Entry<String, JsonNode>> fieldIter = props.fields(); int i = 0; while (fieldIter.hasNext()) { final Map.Entry<String, JsonNode> subNode = fieldIter.next(); // set field name names[i] = subNode.getKey(); // set type types[i] = convertType(location + '/' + subNode.getKey(), subNode.getValue(), root); i++; } // validate that object does not contain additional properties if (node.has(ADDITIONAL_PROPERTIES) && node.get(ADDITIONAL_PROPERTIES).isBoolean() && node.get(ADDITIONAL_PROPERTIES).asBoolean()) { throw new IllegalArgumentException( "An object must not allow additional properties in node: " + location); } return Types.ROW_NAMED(names, types); }
return Types.ROW_NAMED( names.toArray(new String[0]), types.toArray(new TypeInformation<?>[0]));
return Types.ROW_NAMED( names.toArray(new String[0]), types.toArray(new TypeInformation<?>[0]));