public final class DDL extends Object
| Constructor and Description |
|---|
DDL() |
| Modifier and Type | Method and Description |
|---|---|
static io.cdap.cdap.api.data.schema.Schema |
drop(io.cdap.cdap.api.data.schema.Schema schema,
String path)
Drops a path from the schema to generate a new
Schema. |
static io.cdap.cdap.api.data.schema.Schema |
drop(io.cdap.cdap.api.data.schema.Schema schema,
String path,
String... paths) |
static io.cdap.cdap.api.data.format.StructuredRecord |
drop(io.cdap.cdap.api.data.format.StructuredRecord record,
String path) |
static io.cdap.cdap.api.data.format.StructuredRecord |
drop(io.cdap.cdap.api.data.format.StructuredRecord record,
String path,
String... paths) |
static boolean |
hasField(io.cdap.cdap.api.data.format.StructuredRecord record,
String name)
Given a
StructuredRecord and the name of the field, it checks, if the
field exists in the StructuredRecord. |
static io.cdap.cdap.api.data.schema.Schema |
parse(io.cdap.cdap.api.data.schema.Schema schema)
Identity parse method to extract
Schema. |
static io.cdap.cdap.api.data.schema.Schema |
parse(String json)
Given a JSON representation of schema, returns a
Schema object. |
static io.cdap.cdap.api.data.format.StructuredRecord |
parse(io.cdap.cdap.api.data.format.StructuredRecord record)
Given a
StructuredRecord returns the same StructuredRecord. |
static io.cdap.cdap.api.data.schema.Schema |
parsesql(String sql)
Given a SQL DDL, returns the
Schema representation of the SQL. |
static io.cdap.cdap.api.data.schema.Schema |
select(io.cdap.cdap.api.data.schema.Schema schema,
String path)
Selects the sub-record based on the path specified.
|
static <T> T |
select(io.cdap.cdap.api.data.format.StructuredRecord record,
String path)
Select a sub-stucture of a
StructuredRecord. |
static com.google.gson.JsonElement |
toJson(io.cdap.cdap.api.data.format.StructuredRecord record)
Converts a
StructuredRecord to JSON string. |
public static io.cdap.cdap.api.data.schema.Schema parse(String json) throws IOException
Schema object.json - string representation of schema.Schema representing JSON string.IOException - thrown when there is issue parsing the data.public static io.cdap.cdap.api.data.schema.Schema parsesql(String sql) throws IOException
Schema representation of the SQL.sql - to be converted to Schema.Schema.IOException - throw when there is issue parsing the sql.public static io.cdap.cdap.api.data.schema.Schema parse(io.cdap.cdap.api.data.schema.Schema schema)
Schema.
This method is added if a user makes a mistake of parsing the schema again.schema - to be returned.public static io.cdap.cdap.api.data.format.StructuredRecord parse(io.cdap.cdap.api.data.format.StructuredRecord record)
StructuredRecord returns the same StructuredRecord.public static com.google.gson.JsonElement toJson(io.cdap.cdap.api.data.format.StructuredRecord record)
throws IOException
StructuredRecord to JSON string.record - to be converted to JSONIOException - thrown if there are any issues with parsing.public static boolean hasField(io.cdap.cdap.api.data.format.StructuredRecord record,
String name)
StructuredRecord and the name of the field, it checks, if the
field exists in the StructuredRecord.record - in which the field needs to be checked.name - of the field to be checked.public static io.cdap.cdap.api.data.schema.Schema drop(io.cdap.cdap.api.data.schema.Schema schema,
String path)
Schema.schema - to be modified.path - to be removed from Schema.Schemapublic static io.cdap.cdap.api.data.schema.Schema drop(io.cdap.cdap.api.data.schema.Schema schema,
String path,
String... paths)
public static io.cdap.cdap.api.data.schema.Schema select(io.cdap.cdap.api.data.schema.Schema schema,
String path)
schema - to be used as source to apply the path to.path - to be applied on the Schema to select.Schemapublic static io.cdap.cdap.api.data.format.StructuredRecord drop(io.cdap.cdap.api.data.format.StructuredRecord record,
String path)
public static io.cdap.cdap.api.data.format.StructuredRecord drop(io.cdap.cdap.api.data.format.StructuredRecord record,
String path,
String... paths)
public static <T> T select(io.cdap.cdap.api.data.format.StructuredRecord record,
String path)
StructuredRecord.T - type of object returned.record - to be operated onpath - to applied to the StructuredRecordStructuredRecordCopyright © 2020 CDAP Licensed under the Apache License, Version 2.0.