-
Notifications
You must be signed in to change notification settings - Fork 1
UDT #168
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: main
Are you sure you want to change the base?
UDT #168
Conversation
Just FYI @PiotrJunior: I'm not going to review this as long as it has conflicts with the base branch. |
1810f26
to
b396da9
Compare
49dcad6
to
02cd0aa
Compare
b9092ef
to
725fd64
Compare
It this PR ready for the review? |
85d6171
to
d8ed718
Compare
I doubt it is. It has conflicts and the CI is failing. |
// | ||
// This will be fixed at a later time, as it requires more investigation into how UDT works. |
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.
❓ When? As UDT support is added in this PR, I believe you should be now able to solve the problem.
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.
This comment is regarding typeGuessing and I think @adespawn can elaborate on this topic.
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.
This will be fixed in next PR.
Removes CqlTypeClass, to reduce the overhead from it's type. This means, that array will be treated as ambiguous types.
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.
Pull Request Overview
This PR adds support for a new UserDefinedType (UDT) across multiple parts of the codebase including unit tests, integration tests, type wrappers, and request handling. Key changes include:
- Adding new test cases for UDT in unit and integration tests.
- Enhancing Rust type wrappers to support UDT with additional fields and associated methods.
- Updating JavaScript utilities and driver code to properly encode, decode, and wrap UDTs.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
test/unit/query-parameter-tests.js | Added UDT test case to verify proper parameter encoding. |
test/unit/cql-value-wrapper-tests.js | Introduced test for retrieving UDT type values from the N-API. |
test/integration/supported/client-execute-tests.js | Adjusted and commented out UDT/tuple tests; added TODOs for missing features. |
test/integration/supported/client-execute-prepared-tests.js | Updated handling of UDT/tuple tests in prepared statement flows. |
src/types/type_wrappers.rs | Extended ComplexType with UDT-specific fields and helper methods. |
src/tests/result_tests.rs | Added test function for UDT value wrapper functionality. |
src/tests/request_values_tests.rs | Added UDT mapping and sample UDT value in tests. |
src/result.rs | Implemented N-API conversion for UDT in CqlValueWrapper. |
src/requests/parameter_wrappers.rs | Added function to convert UDT parameters from JS arrays to CqlValue. |
lib/types/cql-utils.js | Enhanced UDT encoding logic for driver parameter wrapping. |
examples/DataStax/udt/udt-insert-select.js | Updated example to use dynamic unique key and replication strategy changes. |
Comments suppressed due to low confidence (2)
test/integration/supported/client-execute-tests.js:1183
- Instead of commenting out tests with block comments, consider using a test skip function (e.g., 'xit' or an equivalent) to clearly indicate that the test is intentionally disabled until UDT support is complete.
// TODO: Add support for column information retrieval
test/integration/supported/client-execute-prepared-tests.js:1408
- To enhance clarity and maintainability, use a formal test skip mechanism to disable tests temporarily rather than commenting them out.
// Test for UDT and Tuple support
…-result UUID result
* @param {Object} value | ||
* @param {rust.ComplexType} type | ||
* @returns {Array<rust.ComplexType|Array<Array<String|any>>>} Returns tuple: [rust.ComplexType, [[fieldName, fieldValue]]] | ||
*/ | ||
function encodeUdt(value, type) { |
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.
❓
Returns tuple: [rust.ComplexType, [[fieldName, fieldValue]]]
Really? Double Array? Why?
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.
Because, this function returns array of tuples of field name and value, but in JS tuple is represented as array
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.
Please explain this thoroughly in a comment.
// TODO: Add support for column information retrieval | ||
/* vit("2.1", "should retrieve column information", function (done) { | ||
const client = setupInfo.client; | ||
client.execute( | ||
util.format(selectQuery, sampleId), |
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.
❓ @adespawn @ZuzaOsa @PiotrJunior Do described limitations (unimplemented parts of the driver's API) include missing fields/properties (not only methods)?
// TODO: Add type guessing for UDT and Tuple | ||
/* vit( |
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.
❓ Why isn't this implemented in this PR yet?
❓ When is it going to be implemented?
🔧 If there's no issue for this missing feature yet, please open it!
Uuid = 0x000C, | ||
Varint = 0x000E, | ||
Custom = 0x0000, | ||
Unprovided = 0x0070, |
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.
❓ How can you be sure that there's no type that uses this value? Where did you take it from?
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.
those codes are taken from CQL protocol specification
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.
I'm specifically asking about the Unprovided
variant.
Installing packages with `pip` using the `--user` flag may be the way to avoid permission issues. Let's try this out.
…ci-ccm-permission-errors CI: attempt to fix ccm permission errors
Expand ComplexType to include UDTs.
97c4090
to
9b001dd
Compare
Adds support for converting udt responses to a JavaScript object.
Add tests for converting CQL values to JavaScript values
Adds support for converting JS UDT type into Rust UDT type.
Adds tests for converting JS UDT into Rust CQL values.
Add proper type IDs to the type wrappers. IDs match those in CQL protocol. This is will be useful for testing metadata.
} | ||
const element = getWrapped( | ||
types[i], | ||
value[names[i]] !== undefined ? value[names[i]] : null, // Undefineds should be treated as nulls, so we convert them to nulls. |
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.
value[names[i]] !== undefined ? value[names[i]] : null, // Undefineds should be treated as nulls, so we convert them to nulls. | |
value[names[i]] !== undefined ? value[names[i]] : null, // Undefined values should be treated as null value. |
match pair.get::<Undefined>(1) { | ||
Ok(Some(_)) | Ok(None) => res.push((name, None)), | ||
_ => { | ||
let value = cql_value_from_napi_value(&typ, &pair, 1)?; | ||
res.push((name, Some(value))); | ||
} | ||
} |
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.
Why do we attempt to get undefined, if we can only receive null?
keyspace: _, | ||
name: _, |
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.
Do we loose this information, or did DSX not provide those information in result?
.udt_metadata | ||
.as_ref() | ||
.map(|udt| udt.keyspace.clone()) | ||
.expect("Expected keyspace for UDT") | ||
.clone(), | ||
name: typ | ||
.udt_metadata | ||
.as_ref() | ||
.map(|udt| udt.name.clone()) | ||
.expect("Expected name for UDT") | ||
.clone(), |
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.
Did DataStax provide any possibility to have UDT in unprepared queries?
From what I can see expecting keyspace and name limits it's usage only to prepared queries
.udt_metadata | ||
.as_ref() | ||
.map(|udt| udt.keyspace.clone()) | ||
.expect("Expected keyspace for UDT") | ||
.clone(), |
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.
Shouldn't you use helper function you added: get_udt_keyspace
?
16128e9
to
6300c7f
Compare
Adds UserDefinedType.
Currently not all Integration tests are enabled, as UDT don't support typeHints for now and resultMetadata is not yet supported.