[ 
https://issues.apache.org/jira/browse/BEAM-4196?focusedWorklogId=99790&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-99790
 ]

ASF GitHub Bot logged work on BEAM-4196:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/May/18 23:26
            Start Date: 08/May/18 23:26
    Worklog Time Spent: 10m 
      Work Description: akedin commented on a change in pull request #5276: 
[BEAM-4196][SQL] Support complex types in DDL
URL: https://github.com/apache/beam/pull/5276#discussion_r186895909
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlCliTest.java
 ##########
 @@ -41,13 +50,178 @@ public void testExecute_createTextTable() throws 
Exception {
     cli.execute(
         "create table person (\n"
         + "id int COMMENT 'id', \n"
-        + "name varchar(31) COMMENT 'name', \n"
+        + "name varchar COMMENT 'name', \n"
         + "age int COMMENT 'age') \n"
         + "TYPE 'text' \n"
         + "COMMENT '' LOCATION '/home/admin/orders'"
     );
     Table table = metaStore.getTable("person");
     assertNotNull(table);
+    assertEquals(
+        Stream
+            .of(
+                Field.of("id", 
INTEGER).withDescription("id").withNullable(true),
+                Field.of("name", 
VARCHAR).withDescription("name").withNullable(true),
+                Field.of("age", 
INTEGER).withDescription("age").withNullable(true))
+            .collect(toSchema()),
+        table.getSchema());
+  }
+
+  @Test
+  public void testExecute_createTableWithArrayField() throws Exception {
+    InMemoryMetaStore metaStore = new InMemoryMetaStore();
+    metaStore.registerProvider(new TextTableProvider());
+
+    BeamSqlCli cli = new BeamSqlCli()
+        .metaStore(metaStore);
+    cli.execute(
+        "create table person (\n"
+        + "id int COMMENT 'id', \n"
+        + "name varchar COMMENT 'name', \n"
+        + "age int COMMENT 'age', \n"
+        + "tags VARCHAR ARRAY \n"
+        + ") \n"
+        + "TYPE 'text' \n"
+        + "COMMENT '' LOCATION '/home/admin/orders'"
+    );
+    Table table = metaStore.getTable("person");
+    assertNotNull(table);
+    assertEquals(
+        Stream
+            .of(
+                Field.of("id", 
INTEGER).withDescription("id").withNullable(true),
+                Field.of("name", 
VARCHAR).withDescription("name").withNullable(true),
+                Field.of("age", 
INTEGER).withDescription("age").withNullable(true),
+                Field.of("tags",
+                         
ARRAY.type().withCollectionElementType(VARCHAR)).withNullable(true))
+            .collect(toSchema()),
+        table.getSchema());
+  }
+
+  @Test
+  public void testExecute_createTableWithPrefixArrayField() throws Exception {
+    InMemoryMetaStore metaStore = new InMemoryMetaStore();
+    metaStore.registerProvider(new TextTableProvider());
+
+    BeamSqlCli cli = new BeamSqlCli()
+        .metaStore(metaStore);
+    cli.execute(
+        "create table person (\n"
+        + "id int COMMENT 'id', \n"
+        + "name varchar COMMENT 'name', \n"
+        + "age int COMMENT 'age', \n"
+        + "tags ARRAY<VARCHAR>, \n"
+        + "matrix ARRAY<ARRAY<INTEGER>> \n"
+        + ") \n"
+        + "TYPE 'text' \n"
+        + "COMMENT '' LOCATION '/home/admin/orders'"
+    );
+    Table table = metaStore.getTable("person");
+    assertNotNull(table);
+    assertEquals(
+        Stream
+            .of(
+                Field.of("id", 
INTEGER).withDescription("id").withNullable(true),
+                Field.of("name", 
VARCHAR).withDescription("name").withNullable(true),
+                Field.of("age", 
INTEGER).withDescription("age").withNullable(true),
+                Field.of("tags",
+                         
ARRAY.type().withCollectionElementType(VARCHAR)).withNullable(true),
+                Field.of("matrix",
+                         ARRAY.type().withCollectionElementType(
+                             
ARRAY.type().withCollectionElementType(INTEGER))).withNullable(true))
+            .collect(toSchema()),
+        table.getSchema());
+  }
+
+  @Test
+  public void testExecute_createTableWithPrefixMapField() throws Exception {
+    InMemoryMetaStore metaStore = new InMemoryMetaStore();
+    metaStore.registerProvider(new TextTableProvider());
+
+    BeamSqlCli cli = new BeamSqlCli()
+        .metaStore(metaStore);
+    cli.execute(
+        "create table person (\n"
+        + "id int COMMENT 'id', \n"
+        + "name varchar COMMENT 'name', \n"
+        + "age int COMMENT 'age', \n"
+        + "tags MAP<VARCHAR, VARCHAR>, \n"
+        + "nestedMap MAP<INTEGER, MAP<VARCHAR, INTEGER>> \n"
 
 Review comment:
   Will do

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 99790)
    Time Spent: 3h 10m  (was: 3h)

> [SQL] Support Complex Types in DDL
> ----------------------------------
>
>                 Key: BEAM-4196
>                 URL: https://issues.apache.org/jira/browse/BEAM-4196
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql
>            Reporter: Anton Kedin
>            Assignee: Anton Kedin
>            Priority: Major
>          Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> Neither our DDL parser we copied from calcite-server or the calcite-server 
> don't support complex types in DDL. If we want to model something like JSON 
> objects we need to support at least Arrays and nested Rows.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to