Here are the examples of the java api org.apache.avro.Schema.toString() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
163 Examples
19
Source : FastSerdeBenchmarkSupport.java
with Apache License 2.0
from RTBHOUSE
with Apache License 2.0
from RTBHOUSE
public static void main(String[] args) throws IOException {
if (args.length < 5) {
System.err.println("Usage: FastBenchmarkSupport name depth minNestedRecords maxNestedRecords fieldsNumber");
System.exit(1);
}
String name = args[0];
int depth = Integer.parseInt(args[1]);
int minNestedRecords = Integer.parseInt(args[2]);
int maxNestedRecords = Integer.parseInt(args[3]);
int fieldsNumber = Integer.parseInt(args[4]);
Schema recordSchema = generateRandomRecordSchema(name, depth, minNestedRecords, maxNestedRecords, fieldsNumber);
FileOutputStream avroFileOutputStream = new FileOutputStream(name + ".avsc");
avroFileOutputStream.write(recordSchema.toString(true).getBytes());
}
19
Source : EcoCachedSchemaRegistryClient.java
with Apache License 2.0
from epam
with Apache License 2.0
from epam
private int getSchemaIdFromRegistry(String subject, Schema schema) throws IOException, RestClientException {
io.confluent.kafka.schemaregistry.client.rest.enreplacedies.Schema response = restService.lookUpSubjectVersion(schema.toString(), subject, false);
schemaCache.putIfAbsent(response.getId(), schema);
return response.getId();
}
19
Source : EcoCachedSchemaRegistryClient.java
with Apache License 2.0
from epam
with Apache License 2.0
from epam
private int getSchemaVersionFromRegistry(String subject, Schema schema) throws IOException, RestClientException {
io.confluent.kafka.schemaregistry.client.rest.enreplacedies.Schema response = restService.lookUpSubjectVersion(schema.toString(), subject, true);
schemaCache.putIfAbsent(response.getId(), schema);
return response.getVersion();
}
18
Source : AvroSchemaFormatter.java
with Apache License 2.0
from Talend
with Apache License 2.0
from Talend
public String format(String content) {
Schema schema = new Schema.Parser().parse(content);
return schema.toString(true);
}
18
Source : NCDSTestUtil.java
with Apache License 2.0
from Nasdaq
with Apache License 2.0
from Nasdaq
public String getSchemaForTopic(String schemaFile) throws IOException {
Schema.Parser parser = new Schema.Parser();
Schema schema = parser.parse(ClreplacedLoader.getSystemResourcereplacedtream(schemaFile));
return schema.toString(true);
}
18
Source : BCachedSchemaRegistryClient.java
with Apache License 2.0
from mysql-time-machine
with Apache License 2.0
from mysql-time-machine
public boolean testCompatibility(String subject, Schema schema) throws IOException, RestClientException {
return this.restService.testCompatibility(schema.toString(), subject, "latest");
}
18
Source : BCachedSchemaRegistryClient.java
with Apache License 2.0
from mysql-time-machine
with Apache License 2.0
from mysql-time-machine
private int registerAndGetId(String subject, Schema schema) throws IOException, RestClientException {
return this.restService.registerSchema(schema.toString(), subject);
}
18
Source : BCachedSchemaRegistryClient.java
with Apache License 2.0
from mysql-time-machine
with Apache License 2.0
from mysql-time-machine
private int getVersionFromRegistry(String subject, Schema schema) throws IOException, RestClientException {
io.confluent.kafka.schemaregistry.client.rest.enreplacedies.Schema response = this.restService.lookUpSubjectVersion(schema.toString(), subject, true);
return response.getVersion().intValue();
}
18
Source : BCachedSchemaRegistryClient.java
with Apache License 2.0
from mysql-time-machine
with Apache License 2.0
from mysql-time-machine
private int getIdFromRegistry(String subject, Schema schema) throws IOException, RestClientException {
io.confluent.kafka.schemaregistry.client.rest.enreplacedies.Schema response = this.restService.lookUpSubjectVersion(schema.toString(), subject, false);
return response.getId().intValue();
}
18
Source : GenericRecordAvroTypeInfo.java
with Apache License 2.0
from ljygz
with Apache License 2.0
from ljygz
@Override
public String toString() {
return String.format("GenericRecord(\"%s\")", schema.toString());
}
18
Source : AvroSchemaRegistrySqsAsyncClient.java
with MIT License
from JaidenAshmore
with MIT License
from JaidenAshmore
private Map.Entry<Clreplaced<?>, RegisteredSchema> createObjectMapping(final Schema schema) {
final SchemaRegistrationResponse response = this.schemaRegistryClient.register(schema.getName().toLowerCase(Locale.ENGLISH), AVRO_FORMAT, schema.toString());
log.info("Schema {} registered with id {}", schema.getName(), response.getId());
final Clreplaced<?> clazz;
try {
clazz = Clreplaced.forName(schema.getNamespace() + "." + schema.getName());
} catch (ClreplacedNotFoundException clreplacedNotFoundException) {
throw new RuntimeException(clreplacedNotFoundException);
}
return new AbstractMap.SimpleImmutableEntry<>(clazz, RegisteredSchema.builder().schema(schema).reference(response.getSchemaReference()).build());
}
18
Source : MockExtendedSchemaRegistryClient.java
with Apache License 2.0
from epam
with Apache License 2.0
from epam
private int getIdFromRegistry(String subject, Schema schema) {
Map<Integer, Schema> idSchemaMap;
if (getIdCache().containsKey(subject)) {
idSchemaMap = getIdCache().get(subject);
for (Map.Entry<Integer, Schema> entry : idSchemaMap.entrySet()) {
if (entry.getValue().toString().equals(schema.toString())) {
return entry.getKey();
}
}
}
return (int) callClientMethod("getIdFromRegistry", new Clreplaced[] { String.clreplaced, Schema.clreplaced, boolean.clreplaced }, subject, schema, Boolean.TRUE);
}
18
Source : EcoCachedSchemaRegistryClient.java
with Apache License 2.0
from epam
with Apache License 2.0
from epam
private int registerAndGetId(String subject, Schema schema, int version, int id) throws IOException, RestClientException {
return restService.registerSchema(schema.toString(), subject, version, id);
}
18
Source : SerializableSchema.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static Schema newCopy(Schema schemaObject) {
return new Schema.Parser().parse(schemaObject.toString());
}
18
Source : SerializableSchema.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public String toString() {
return schema.toString();
}
18
Source : TestUpsertPartitioner.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private HoodieWriteConfig.Builder makeHoodieClientConfigBuilder() {
// Prepare the AvroParquetIO
return HoodieWriteConfig.newBuilder().withPath(basePath).withSchema(SCHEMA.toString());
}
18
Source : TestUpdateSchemaEvolution.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private HoodieWriteConfig makeHoodieClientConfig(String name) {
Schema schema = getSchemaFromResource(getClreplaced(), name);
return HoodieWriteConfig.newBuilder().withPath(basePath).withSchema(schema.toString()).build();
}
17
Source : TestAvroConfluentRowDecoder.java
with Apache License 2.0
from trinodb
with Apache License 2.0
from trinodb
private static RowDecoder getRowDecoder(SchemaRegistryClient schemaRegistryClient, Set<DecoderColumnHandle> columnHandles, Schema schema) {
ImmutableMap<String, String> decoderParams = ImmutableMap.<String, String>builder().put(DATA_SCHEMA, schema.toString()).build();
return getAvroRowDecoderyFactory(schemaRegistryClient).create(decoderParams, columnHandles);
}
17
Source : NCDSClient.java
with Apache License 2.0
from Nasdaq
with Apache License 2.0
from Nasdaq
/**
* Returns Schema for Topic/Stream r Object
* @param topic - Topic/Stream name
* @return - Kafka Schema
* @throws Exception - Java Exception
*/
public String getSchemaForTheTopic(String topic) throws Exception {
try {
Schema kafkaSchema = nasdaqKafkaAvroConsumer.getSchemaForTopic(topic);
return kafkaSchema.toString(true);
} catch (Exception e) {
throw (e);
}
}
17
Source : EventDataPresenterAvroTest.java
with Apache License 2.0
from mysql-time-machine
with Apache License 2.0
from mysql-time-machine
@Test
public void testDefaultValuesInGeneratedAvroSchema() throws Exception {
EventDataPresenterAvro dataPresenter = new EventDataPresenterAvro(new AugmentedEvent());
ArrayList<ColumnSchema> columns = new ArrayList<>();
columns.add(new ColumnSchema("col1", DataType.INT, "int(11)", true, "", ""));
columns.add(new ColumnSchema("col2", DataType.INT, "int(11)", true, "", "").setDefaultValue("10"));
columns.add(new ColumnSchema("col3", DataType.ENUM, "enum('boolean','integer','string','date','datetime','boolarray','intarray','stringarray','datearray','enum')", true, "", "").setDefaultValue("string"));
Schema avroSchema = dataPresenter.createAvroSchema(false, true, new FullTableName("db", "table"), columns);
String expected = "{\"type\":\"record\",\"name\":\"table\",\"namespace\":\"db\",\"fields\":[{\"name\":\"col1\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"col2\",\"type\":[\"int\",\"null\"],\"default\":10},{\"name\":\"col3\",\"type\":[\"string\",\"null\"],\"default\":\"string\"}]}";
replacedertEquals(expected, avroSchema.toString());
}
17
Source : SinkConfig.java
with MIT License
from mercari
with MIT License
from mercari
public void outputAvroSchema(final Schema schema) {
if (outputAvroSchema == null) {
return;
}
if (!outputAvroSchema.startsWith("gs://")) {
throw new IllegalArgumentException("Parameter outputAvroSchema is illegal: " + outputAvroSchema);
}
if (schema == null) {
throw new IllegalArgumentException("Required schema when outputAvroSchema specified: " + outputAvroSchema);
}
try {
StorageUtil.writeString(outputAvroSchema, schema.toString(true));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
17
Source : SerializableAvroSchema.java
with Apache License 2.0
from ljygz
with Apache License 2.0
from ljygz
private void writeObject(ObjectOutputStream oos) throws IOException {
if (schema == null) {
oos.writeBoolean(false);
} else {
oos.writeBoolean(true);
oos.writeUTF(schema.toString(false));
}
}
17
Source : GenericRecordAvroTypeInfo.java
with Apache License 2.0
from ljygz
with Apache License 2.0
from ljygz
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.writeUTF(schema.toString());
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testFilter() {
String viewSql = "CREATE VIEW v AS " + "SELECT bc.Id AS Id_View_Col, bc.Array_Col AS Array_View_Col " + "FROM basecomplex bc " + "WHERE bc.Id > 0 AND bc.Struct_Col IS NOT NULL";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testFilter-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testSelectStar() {
String viewSql = "CREATE VIEW v AS SELECT * FROM basecomplex";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testSelectStar-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testBaseTableWithParreplacedion() {
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "basecasepreservation");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testBaseTableWithParreplacedon-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testNullabilityUdf() {
String viewSql = "CREATE VIEW foo_dali_udf_nullability " + "tblproperties('functions' = 'LessThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF1 GreaterThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF2 FuncSquare:com.linkedin.coral.hive.hive2rel.CoralTestUDF3', " + " 'dependencies' = 'ivy://com.linkedin:udf:1.0 ivy://com.linkedin:udf:1.0 ivy://com.linkedin:udf:1.0') " + "AS " + "SELECT default_foo_dali_udf_nullability_LessThanHundred(Int_Field_1), " + "default_foo_dali_udf_nullability_LessThanHundred(Int_Field_2), " + "default_foo_dali_udf_nullability_GreaterThanHundred(Int_Field_1), " + "default_foo_dali_udf_nullability_GreaterThanHundred(Int_Field_2), " + "default_foo_dali_udf_nullability_FuncSquare(Int_Field_1), " + "default_foo_dali_udf_nullability_FuncSquare(Int_Field_2), " + "default_foo_dali_udf_nullability_LessThanHundred(Int_Field_1) AND default_foo_dali_udf_nullability_LessThanHundred(Int_Field_2), " + "default_foo_dali_udf_nullability_GreaterThanHundred(Int_Field_1) OR default_foo_dali_udf_nullability_GreaterThanHundred(Int_Field_2), " + "default_foo_dali_udf_nullability_FuncSquare(Int_Field_1) + Id, " + "default_foo_dali_udf_nullability_FuncSquare(Int_Field_2) + Id, " + "CONCAT(String_Field_1,String_Field_1), " + "CONCAT(String_Field_2,String_Field_2), " + "CONCAT(String_Field_1,String_Field_2), " + "default_foo_dali_udf_nullability_FuncSquare(Int_Field_1) + 1, " + "default_foo_dali_udf_nullability_FuncSquare(Int_Field_2 + 1) + 1, " + "default_foo_dali_udf_nullability_FuncSquare(default_foo_dali_udf_nullability_FuncSquare(default_foo_dali_udf_nullability_FuncSquare(Int_Field_2))) + bn.Id, " + "default_foo_dali_udf_nullability_FuncSquare(default_foo_dali_udf_nullability_FuncSquare(default_foo_dali_udf_nullability_FuncSquare(Int_Field_2)) + 1) + bn.Id, " + "default_foo_dali_udf_nullability_FuncSquare(Int_Field_2 + Id) + Id, " + "Id + default_foo_dali_udf_nullability_FuncSquare(Id) " + "FROM basenullability bn";
TestUtils.executeCreateViewQuery("default", "foo_dali_udf_nullability", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "foo_dali_udf_nullability");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testNullabilityUdf-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testUnionSelectStarFromParreplacedionTable() {
String viewSql = "CREATE VIEW v AS " + "SELECT * FROM basecasepreservation " + "UNION ALL " + "SELECT * FROM basecasepreservation";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testSelectStarWithParreplacedion.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testNullabilityBasic() {
String viewSql = "CREATE VIEW v AS " + "SELECT bn.Id, " + "bn.Array_Col, " + "bn.Map_Col, " + "bn.Int_Field_1, " + "bn.Int_Field_2, " + "bn.Double_Field_1, " + "bn.Double_Field_2, " + "bn.Bool_Field_1, " + "bn.Bool_Field_2, " + "bn.String_Field_1, " + "bn.String_Field_2, " + "bn.Struct_Col " + "FROM basenullability bn";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testNullabilityBasic-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testMultipleUdfs() {
String viewSql = "CREATE VIEW foo_dali_multiple_udfs " + "tblproperties('functions' = 'LessThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF1 GreaterThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF2 FuncSquare:com.linkedin.coral.hive.hive2rel.CoralTestUDF3', " + " 'dependencies' = 'ivy://com.linkedin:udf:1.0 ivy://com.linkedin:udf:1.0 ivy://com.linkedin:udf:1.0') " + "AS " + "SELECT Id AS Id_Viewc_Col, " + "default_foo_dali_multiple_udfs_LessThanHundred(Id) AS Id_View_LessThanHundred_Col," + "default_foo_dali_multiple_udfs_GreaterThanHundred(Id) AS Id_View_GreaterThanHundred_Col, " + "default_foo_dali_multiple_udfs_FuncSquare(Id) AS Id_View_FuncSquare_Col " + "FROM basecomplex";
TestUtils.executeCreateViewQuery("default", "foo_dali_multiple_udfs", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "foo_dali_multiple_udfs");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testMultipleUdfs-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testLateralViewOuter() {
String viewSql = "CREATE VIEW v AS " + "SELECT bc.Id AS Id_View_Col, t.Array_Lateral_View_Col " + "FROM basecomplex bc " + "LATERAL VIEW OUTER explode(bc.Array_Col) t as Array_Lateral_View_Col";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testLateralViewOuter-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testUdfGreaterThanHundred() {
String viewSql = "CREATE VIEW foo_dali_udf2 " + "tblproperties('functions' = 'GreaterThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF2', " + " 'dependencies' = 'ivy://com.linkedin:udf:1.0') " + "AS " + "SELECT Id AS Id_Viewc_Col, default_foo_dali_udf2_GreaterThanHundred(Id) AS Id_View_GreaterThanHundred_Col " + "FROM basecomplex";
TestUtils.executeCreateViewQuery("default", "foo_dali_udf2", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "foo_dali_udf2");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testUdfGreaterThanHundred-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testInnerJoin() {
String viewSql = "CREATE VIEW v AS " + "SELECT bc.id, bc.struct_col, be.enum_top_col " + "FROM basecomplex bc " + "JOIN baseenum be ON bc.id = be.id " + "WHERE bc.id > 0 AND bc.struct_col IS NOT NULL";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testJoin-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testRexCallAggregateMultiple() {
String viewSql = "CREATE VIEW v AS " + "SELECT bc.Id, 22*COUNT(bc.Array_Col) AS Array_Count, 33*COUNT(bc.Map_Col) AS Map_Count, COUNT(bc.Array_Col), COUNT(bc.Map_Col) " + "FROM basecomplex bc " + "WHERE bc.Id > 0 " + "GROUP BY bc.Id";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testRexCallAggregateMultiple-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testSelectStarFromNestComplex() {
String viewSql = "CREATE VIEW v AS SELECT * FROM basenestedcomplex";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testSelectStarFromNestComplex-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testSelectWithMultipleLiterals() {
String viewSql = "CREATE VIEW v AS " + "SELECT 200, 1, bc.Id AS Id_View_Col, 100 AS Additional_Int, 200, 1, 1, 1, bc.Array_Col " + "FROM basecomplex bc";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testSelectWithMultipleLiterals-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testNullabilitySqlOperator() {
String viewSql = "CREATE VIEW v AS " + "SELECT bn.Id + bn.Int_Field_1, " + "bn.Id + bn.Int_Field_2, " + "bn.Int_Field_1 + bn.Int_Field_1, " + "bn.Int_Field_1 + 1, " + "bn.Int_Field_2 + 1, " + "bn.Double_Field_1 + bn.Double_Field_1, " + "bn.Double_Field_2 + bn.Double_Field_2, " + "bn.Double_Field_1 + bn.Double_Field_2, " + "NOT bn.Bool_Field_1, " + "NOT bn.Bool_Field_2 " + "FROM basenullability bn";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testNullabilitySqlOperator-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testUdfWithOperator() {
String viewSql = "CREATE VIEW foo_dali_udf_with_operator " + "tblproperties('functions' = 'LessThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF1 GreaterThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF2 FuncSquare:com.linkedin.coral.hive.hive2rel.CoralTestUDF3', " + " 'dependencies' = 'ivy://com.linkedin:udf:1.0 ivy://com.linkedin:udf:1.0 ivy://com.linkedin:udf:1.0') " + "AS " + "SELECT Id AS Id_Viewc_Col, " + "default_foo_dali_udf_with_operator_LessThanHundred(Id)," + "default_foo_dali_udf_with_operator_GreaterThanHundred(Id), " + "default_foo_dali_udf_with_operator_FuncSquare(Id), " + "1 + 1, " + "Id + 1, " + "default_foo_dali_udf_with_operator_FuncSquare(Id) + 1, " + "default_foo_dali_udf_with_operator_FuncSquare(Id + 1) + 1, " + "Id + default_foo_dali_udf_with_operator_FuncSquare(Id) " + "FROM basecomplex";
TestUtils.executeCreateViewQuery("default", "foo_dali_udf_with_operator", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "foo_dali_udf_with_operator");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testUdfWithOperator-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testUnionPreserveNamespace() {
String viewSql = "CREATE VIEW v AS " + "SELECT * FROM basecasepreservation " + "UNION ALL " + "SELECT * FROM basecasepreservation";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v", true);
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testUnionPreserveNamespace.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testSubQueryFrom() {
String viewSql = "CREATE VIEW v AS " + "SELECT Id, Map_Col " + "FROM " + "( " + "SELECT Id, Map_Col " + "FROM basecomplex " + "WHERE Id > 0 AND Struct_Col IS NOT NULL " + ") t";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testSubQueryFrom-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testLeftOuterJoin() {
String viewSql = "CREATE VIEW v AS " + "SELECT bc.id, bc.struct_col, be.enum_top_col " + "FROM basecomplex bc " + "LEFT OUTER JOIN baseenum be ON bc.id = be.id " + "WHERE bc.id > 0 AND bc.struct_col IS NOT NULL";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testJoin-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testLateralView() {
String viewSql = "CREATE VIEW v AS " + "SELECT bc.Id AS Id_View_Col, t.Array_Lateral_View_Col " + "FROM basecomplex bc " + "LATERAL VIEW explode(bc.Array_Col) t as Array_Lateral_View_Col";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testLateralView-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testMultipleLateralViewDifferentArrayType() {
String viewSql = "CREATE VIEW v AS " + "SELECT bl.Id AS Id_View_Col, t1.Array_Lateral_View_String_Col, t2.Array_Lateral_View_Double_Col " + "FROM baselateralview bl " + "LATERAL VIEW explode(bl.Array_Col_String) t1 as Array_Lateral_View_String_Col " + "LATERAL VIEW explode(bl.Array_Col_Double) t2 as Array_Lateral_View_Double_Col";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testMultipleLateralViewDifferentArrayType-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testBaseTableWithFieldSchema() {
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "basecomplexfieldschema");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testBaseTableWithFieldSchema-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
// TODO: handle complex type (Array[Struct] in lateral view: LIHADOOP-46695)
@Test(enabled = false)
public void testLateralViewArrayWithComplexType() {
String viewSql = "CREATE VIEW v AS " + "SELECT bl.Id AS Id_View_Col, bl.Array_Col_Struct AS Array_Struct_View_Col, " + "t.Array_Col_Struct_Flatten " + "FROM baselateralview bl " + "LATERAL VIEW explode(bl.Array_Col_Struct) t as Array_Col_Struct_Flatten";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testLateralViewArrayWithComplexType-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testRightOuterJoin() {
String viewSql = "CREATE VIEW v AS " + "SELECT bc.id, bc.struct_col, be.enum_top_col " + "FROM basecomplex bc " + "RIGHT OUTER JOIN baseenum be ON bc.id = be.id " + "WHERE bc.id > 0 AND bc.struct_col IS NOT NULL";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testJoin-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testSelectWithLiterals() {
String viewSql = "CREATE VIEW v AS " + "SELECT bc.Id AS Id_View_Col, 100 AS Additional_Int, 200, bc.Array_Col AS Array_View_Col " + "FROM basecomplex bc " + "WHERE bc.Id > 0 AND bc.Struct_Col IS NOT NULL";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testSelectWithLiterals-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testUdfSquare() {
String viewSql = "CREATE VIEW foo_dali_udf3 " + "tblproperties('functions' = 'FuncSquare:com.linkedin.coral.hive.hive2rel.CoralTestUDF3', " + " 'dependencies' = 'ivy://com.linkedin:udf:1.0') " + "AS " + "SELECT Id AS Id_Viewc_Col, default_foo_dali_udf3_FuncSquare(Id) AS Id_View_FuncSquare_Col " + "FROM basecomplex";
TestUtils.executeCreateViewQuery("default", "foo_dali_udf3", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "foo_dali_udf3");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testUdfSquare-expected.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testUnionNotPreserveNamespace() {
String viewSql = "CREATE VIEW v AS " + "SELECT * FROM basecasepreservation " + "UNION ALL " + "SELECT * FROM basecasepreservation";
TestUtils.executeCreateViewQuery("default", "v", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "v", false);
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testSelectStarWithParreplacedion.avsc"));
}
17
Source : ViewToAvroSchemaConverterTests.java
with BSD 2-Clause "Simplified" License
from linkedin
with BSD 2-Clause "Simplified" License
from linkedin
@Test
public void testUdfLessThanHundred() {
String viewSql = "CREATE VIEW foo_dali_udf " + "tblproperties('functions' = 'LessThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF1', " + " 'dependencies' = 'ivy://com.linkedin:udf:1.0') " + "AS " + "SELECT Id AS Id_View_Col, default_foo_dali_udf_LessThanHundred(Id) AS Id_View_LessThanHundred_Col " + "FROM basecomplex";
TestUtils.executeCreateViewQuery("default", "foo_dali_udf", viewSql);
ViewToAvroSchemaConverter viewToAvroSchemaConverter = ViewToAvroSchemaConverter.create(hiveMetastoreClient);
Schema actualSchema = viewToAvroSchemaConverter.toAvroSchema("default", "foo_dali_udf");
replacedert.replacedertEquals(actualSchema.toString(true), TestUtils.loadSchema("testUdfLessThanHundred-expected.avsc"));
}
See More Examples