Search in sources :

Example 21 with SamzaSqlRelRecord

use of org.apache.samza.sql.SamzaSqlRelRecord in project samza by apache.

the class TestGetSqlFieldUdf method testMultiLevelInvalidIntermediateField.

@Test(expected = IllegalArgumentException.class)
public void testMultiLevelInvalidIntermediateField() {
    SamzaSqlRelRecord record = createRecord("bar.baz.baf.foo");
    GetSqlFieldUdf getSqlFieldUdf = new GetSqlFieldUdf();
    getSqlFieldUdf.execute(record, "bar.baz.bacon");
}
Also used : SamzaSqlRelRecord(org.apache.samza.sql.SamzaSqlRelRecord) Test(org.junit.Test)

Example 22 with SamzaSqlRelRecord

use of org.apache.samza.sql.SamzaSqlRelRecord in project samza by apache.

the class TestGetSqlFieldUdf method testSingleLevel.

@Test
public void testSingleLevel() {
    SamzaSqlRelRecord record = createRecord("foo");
    GetSqlFieldUdf getSqlFieldUdf = new GetSqlFieldUdf();
    Assert.assertEquals(getSqlFieldUdf.execute(record, "foo"), "bar");
}
Also used : SamzaSqlRelRecord(org.apache.samza.sql.SamzaSqlRelRecord) Test(org.junit.Test)

Example 23 with SamzaSqlRelRecord

use of org.apache.samza.sql.SamzaSqlRelRecord in project samza by apache.

the class TestGetSqlFieldUdf method testArrayAtIntermediateFields.

@Test
public void testArrayAtIntermediateFields() {
    SamzaSqlRelRecord record = createRecord("bar.baz[3].baf[2].foo");
    GetSqlFieldUdf getSqlFieldUdf = new GetSqlFieldUdf();
    Assert.assertEquals(getSqlFieldUdf.execute(record, "bar.baz[3].baf[2].foo"), "bar");
}
Also used : SamzaSqlRelRecord(org.apache.samza.sql.SamzaSqlRelRecord) Test(org.junit.Test)

Example 24 with SamzaSqlRelRecord

use of org.apache.samza.sql.SamzaSqlRelRecord in project samza by apache.

the class TestGetSqlFieldUdf method testSingleLevelInvalidField.

@Test(expected = IllegalArgumentException.class)
public void testSingleLevelInvalidField() {
    SamzaSqlRelRecord record = createRecord("foo");
    GetSqlFieldUdf getSqlFieldUdf = new GetSqlFieldUdf();
    getSqlFieldUdf.execute(record, "bar");
}
Also used : SamzaSqlRelRecord(org.apache.samza.sql.SamzaSqlRelRecord) Test(org.junit.Test)

Example 25 with SamzaSqlRelRecord

use of org.apache.samza.sql.SamzaSqlRelRecord in project samza by apache.

the class TestSamzaSqlRelRecordSerde method testWithDifferentFields.

@Test
public void testWithDifferentFields() {
    SamzaSqlRelRecord record = new SamzaSqlRelMessage(names, values, new SamzaSqlRelMsgMetadata(0L, 0L)).getSamzaSqlRelRecord();
    SamzaSqlRelRecordSerde serde = (SamzaSqlRelRecordSerde) new SamzaSqlRelRecordSerdeFactory().getSerde(null, null);
    SamzaSqlRelRecord resultRecord = serde.fromBytes(serde.toBytes(record));
    Assert.assertEquals(names, resultRecord.getFieldNames());
    Assert.assertEquals(values, resultRecord.getFieldValues());
}
Also used : SamzaSqlRelMsgMetadata(org.apache.samza.sql.data.SamzaSqlRelMsgMetadata) SamzaSqlRelRecord(org.apache.samza.sql.SamzaSqlRelRecord) SamzaSqlRelRecordSerde(org.apache.samza.sql.serializers.SamzaSqlRelRecordSerdeFactory.SamzaSqlRelRecordSerde) SamzaSqlRelMessage(org.apache.samza.sql.data.SamzaSqlRelMessage) Test(org.junit.Test)

Aggregations

SamzaSqlRelRecord (org.apache.samza.sql.SamzaSqlRelRecord)31 Test (org.junit.Test)25 ArrayList (java.util.ArrayList)6 SamzaSqlRelMessage (org.apache.samza.sql.data.SamzaSqlRelMessage)5 List (java.util.List)3 Schema (org.apache.avro.Schema)3 JoinRelType (org.apache.calcite.rel.core.JoinRelType)3 SamzaSqlRelMsgMetadata (org.apache.samza.sql.data.SamzaSqlRelMsgMetadata)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 GenericData (org.apache.avro.generic.GenericData)2 ByteString (org.apache.calcite.avatica.util.ByteString)2 SamzaException (org.apache.samza.SamzaException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Collections (java.util.Collections)1 LinkedList (java.util.LinkedList)1 Collectors (java.util.stream.Collectors)1 GenericRecord (org.apache.avro.generic.GenericRecord)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1