-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Struct Data Type(Part-1): New struct type, DDL statements and Describe #1114
Changes from all commits
322f8f2
0911202
f69c25c
3e6200b
415aa49
0253884
3846f4c
7893e2c
f391466
b45efb0
4af44e3
38c5456
f84d561
e885e75
fa1a261
0f68684
ef41a33
e1821cf
511f5e3
7032379
8b58d47
1e96708
41eeb16
2e1d04d
c2e05f3
02983f6
e19bfb7
dabfab2
46ce7e8
d5493ba
b873594
6a60bf7
7c84bf5
01b2871
2050f03
aab1f09
1bf87ba
f4083d8
127babb
17334bb
df70636
c4626bc
f75ea11
604cbfd
dc6e63c
f4745ea
c3bfd72
096d37e
e7399d6
c106874
434bf5d
6fb6bcb
5517b54
787a8a8
30bcab0
cb50d56
573c28a
8a6e836
83e06c0
4be7b47
d625753
ab80df9
87dc0da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,4 +295,44 @@ public void shouldReturnFieldNameWithoutAliasAsIs() { | |
assertThat("Invalid field name", SchemaUtil.getFieldNameWithNoAlias(schema.fields().get(0)), | ||
equalTo(schema.fields().get(0).name())); | ||
} | ||
|
||
@Test | ||
public void shouldCreateCorrectSchemaDescription() { | ||
Schema addressSchema = SchemaBuilder.struct() | ||
.field("NUMBER", Schema.INT64_SCHEMA) | ||
.field("STREET", Schema.STRING_SCHEMA) | ||
.field("CITY", Schema.STRING_SCHEMA) | ||
.field("STATE", Schema.STRING_SCHEMA) | ||
.field("ZIPCODE", Schema.INT64_SCHEMA) | ||
.build(); | ||
|
||
SchemaBuilder schemaBuilder = SchemaBuilder.struct(); | ||
Schema structSchema = schemaBuilder | ||
.field("ordertime", Schema.INT64_SCHEMA) | ||
.field("orderid", Schema.INT64_SCHEMA) | ||
.field("itemid", Schema.STRING_SCHEMA) | ||
.field("orderunits", Schema.FLOAT64_SCHEMA) | ||
.field("arraycol",schemaBuilder.array(Schema.FLOAT64_SCHEMA)) | ||
.field("mapcol", schemaBuilder.map(Schema.STRING_SCHEMA, Schema.FLOAT64_SCHEMA)) | ||
.field("address", addressSchema).build(); | ||
|
||
String schemaDescription = SchemaUtil.describeSchema(structSchema); | ||
|
||
assertThat(schemaDescription, equalTo("STRUCT < \n" | ||
+ "\t ordertime BIGINT, \n" | ||
+ "\t orderid BIGINT, \n" | ||
+ "\t itemid VARCHAR(STRING), \n" | ||
+ "\t orderunits DOUBLE, \n" | ||
+ "\t arraycol ARRAY[DOUBLE], \n" | ||
+ "\t mapcol MAP[VARCHAR(STRING),DOUBLE], \n" | ||
+ "\t address STRUCT < \n" | ||
+ "\t NUMBER BIGINT, \n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be nice to add an indent here. I'm fine with punting this to another PR though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, for now I'll leave it as is. We may want to provide unified ux for both web based UI and CLI |
||
+ "\t STREET VARCHAR(STRING), \n" | ||
+ "\t CITY VARCHAR(STRING), \n" | ||
+ "\t STATE VARCHAR(STRING), \n" | ||
+ "\t ZIPCODE BIGINT\n" | ||
+ " >\n" | ||
+ " >")); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stringBuilder.append(
field.schema().fields().stream()
.map(getSchemaFieldType)
.collect(Collectors.joining(", ")));