-
Notifications
You must be signed in to change notification settings - Fork 26
STREAM-770: Added support for tuple datatype #217
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
2823adb
02168b6
3bdd97a
135e51e
d075cdd
9fe522d
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 |
|---|---|---|
|
|
@@ -22,7 +22,10 @@ | |
| import com.datastax.oss.driver.api.core.cql.BatchType; | ||
| import com.datastax.oss.driver.api.core.cql.PreparedStatement; | ||
| import com.datastax.oss.driver.api.core.data.CqlDuration; | ||
| import com.datastax.oss.driver.api.core.data.TupleValue; | ||
| import com.datastax.oss.driver.api.core.data.UdtValue; | ||
| import com.datastax.oss.driver.api.core.type.DataTypes; | ||
| import com.datastax.oss.driver.api.core.type.TupleType; | ||
| import com.datastax.oss.driver.api.core.type.UserDefinedType; | ||
| import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableSet; | ||
| import com.datastax.oss.driver.shaded.guava.common.collect.Lists; | ||
|
|
@@ -648,16 +651,17 @@ public void testSchema(String ksName) throws InterruptedException, IOException { | |
| // force udt values to be null by populating 1 item, using zudt.newValue() without explicitly setting | ||
| // any field to non-null value will cause the udt column itself to be null in the C* table | ||
| UdtValue zudtOptionalValues = zudt.newValue(dataSpecMap.get("text").cqlValue); | ||
|
|
||
| TupleType tupleType = DataTypes.tupleOf(DataTypes.INT, DataTypes.TEXT); | ||
|
Member
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. Will you please able to add a complex test case of a CQL column of type |
||
| TupleValue tupleValue = tupleType.newValue(dataSpecMap.get("int").cqlValue, dataSpecMap.get("text").cqlValue); | ||
| cqlSession.execute("CREATE TABLE IF NOT EXISTS " + ksName + ".table3 (" + | ||
| "xtext text, xascii ascii, xboolean boolean, xblob blob, xtimestamp timestamp, xtime time, xdate date, xuuid uuid, xtimeuuid timeuuid, xtinyint tinyint, xsmallint smallint, xint int, xbigint bigint, xvarint varint, xdecimal decimal, xdouble double, xfloat float, xinet4 inet, xinet6 inet, " + | ||
| "ytext text, yascii ascii, yboolean boolean, yblob blob, ytimestamp timestamp, ytime time, ydate date, yuuid uuid, ytimeuuid timeuuid, ytinyint tinyint, ysmallint smallint, yint int, ybigint bigint, yvarint varint, ydecimal decimal, ydouble double, yfloat float, yinet4 inet, yinet6 inet, yduration duration, yudt zudt, yudtoptional zudt, ylist list<text>, yset set<int>, ymap map<text, double>, ylistofmap list<frozen<map<text,double>>>, ysetofudt set<frozen<zudt>>," + | ||
| "ytext text, yascii ascii, yboolean boolean, yblob blob, ytimestamp timestamp, ytime time, ydate date, yuuid uuid, ytimeuuid timeuuid, ytinyint tinyint, ysmallint smallint, yint int, ybigint bigint, yvarint varint, ydecimal decimal, ydouble double, yfloat float, yinet4 inet, yinet6 inet, yduration duration, yudt zudt, yudtoptional zudt, ylist list<text>, yset set<int>, ymap map<text, double>, ytuple frozen<tuple<int, text>>, ylistofmap list<frozen<map<text,double>>>, ysetofudt set<frozen<zudt>>," + | ||
| "primary key (xtext, xascii, xboolean, xblob, xtimestamp, xtime, xdate, xuuid, xtimeuuid, xtinyint, xsmallint, xint, xbigint, xvarint, xdecimal, xdouble, xfloat, xinet4, xinet6)) " + | ||
| "WITH CLUSTERING ORDER BY (xascii ASC, xboolean DESC, xblob ASC, xtimestamp DESC, xtime DESC, xdate ASC, xuuid DESC, xtimeuuid ASC, xtinyint DESC, xsmallint ASC, xint DESC, xbigint ASC, xvarint DESC, xdecimal ASC, xdouble DESC, xfloat ASC, xinet4 ASC, xinet6 DESC) AND cdc=true"); | ||
| cqlSession.execute("INSERT INTO " + ksName + ".table3 (" + | ||
| "xtext, xascii, xboolean, xblob, xtimestamp, xtime, xdate, xuuid, xtimeuuid, xtinyint, xsmallint, xint, xbigint, xvarint, xdecimal, xdouble, xfloat, xinet4, xinet6, " + | ||
| "ytext, yascii, yboolean, yblob, ytimestamp, ytime, ydate, yuuid, ytimeuuid, ytinyint, ysmallint, yint, ybigint, yvarint, ydecimal, ydouble, yfloat, yinet4, yinet6, yduration, yudt, yudtoptional, ylist, yset, ymap, ylistofmap, ysetofudt" + | ||
| ") VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?, ?,?,?,?,?)", | ||
| "ytext, yascii, yboolean, yblob, ytimestamp, ytime, ydate, yuuid, ytimeuuid, ytinyint, ysmallint, yint, ybigint, yvarint, ydecimal, ydouble, yfloat, yinet4, yinet6, yduration, yudt, yudtoptional, ylist, yset, ymap, ytuple, ylistofmap, ysetofudt" + | ||
| ") VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?, ?,?,?,?,?,?)", | ||
| dataSpecMap.get("text").cqlValue, | ||
| dataSpecMap.get("ascii").cqlValue, | ||
| dataSpecMap.get("boolean").cqlValue, | ||
|
|
@@ -705,6 +709,7 @@ public void testSchema(String ksName) throws InterruptedException, IOException { | |
| dataSpecMap.get("list").cqlValue, | ||
| dataSpecMap.get("set").cqlValue, | ||
| dataSpecMap.get("map").cqlValue, | ||
| tupleValue, | ||
| dataSpecMap.get("listofmap").cqlValue, | ||
| ImmutableSet.of(zudtValue, zudtValue) | ||
| ); | ||
|
|
@@ -809,8 +814,17 @@ void assertGenericArray(String field, GenericArray ga) { | |
| } | ||
|
|
||
| void assertField(String fieldName, Object value) { | ||
| if (fieldName.startsWith("index_")) { | ||
| int idx = Integer.parseInt(fieldName.substring("index_".length())); | ||
| if (idx == 0) { | ||
| Assert.assertEquals(dataSpecMap.get("int").avroValue, value); | ||
| } else if (idx == 1) { | ||
|
Member
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. I don't understand this fully, so please bear with my limited knowledge here. Are we stopping just at the 2nd field? What if the tuple field has more than 2 fileds? |
||
| Assert.assertEquals(dataSpecMap.get("text").avroValue, value); | ||
| } | ||
| return; | ||
| } | ||
| String vKey = fieldName.substring(1); | ||
| if (!vKey.equals("udt") && !vKey.equals("udtoptional") && ! vKey.equals("setofudt")) { | ||
| if (!vKey.equals("udt") && !vKey.equals("udtoptional") && ! vKey.equals("setofudt") && !vKey.equals("tuple")) { | ||
| Assert.assertTrue("Unknown field " + vKey, dataSpecMap.containsKey(vKey)); | ||
| } | ||
| if (value instanceof GenericRecord) { | ||
|
|
@@ -878,6 +892,12 @@ void assertGenericRecords(String field, GenericRecord gr) { | |
| } | ||
| } | ||
| return; | ||
| case "tuple": { | ||
priyanshu-ctds marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for (Field f : gr.getFields()) { | ||
| assertField(f.getName(), gr.getField(f.getName())); | ||
| } | ||
| } | ||
| return; | ||
| } | ||
| Assert.assertTrue("Unexpected field="+field, false); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.