-
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
Open
priyanshu-ctds
wants to merge
6
commits into
master
Choose a base branch
from
stream770
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+78
−5
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2823adb
Added support for tuple datatype
priyanshu-ctds 02168b6
Modified test to include the tuple data type
priyanshu-ctds 3bdd97a
Separated case
priyanshu-ctds 135e51e
Added value
priyanshu-ctds d075cdd
Merged cases with similar block and tunred optional to true
priyanshu-ctds 9fe522d
nitpick formatting review comments
msmygit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| 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) { | ||
|
|
@@ -861,6 +875,7 @@ void assertGenericRecords(String field, GenericRecord gr) { | |
| (long) gr.getField(CqlLogicalTypes.CQL_DURATION_NANOSECONDS))); | ||
| } | ||
| return; | ||
| case "tuple": | ||
| case "udt": { | ||
| for (Field f : gr.getFields()) { | ||
| assertField(f.getName(), gr.getField(f.getName())); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will you please able to add a complex test case of a CQL column of type
map<text, frozen<tuple<text, text, bigint, double, text>>>in addition to the simple tuple type here?