Skip to content
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

Add convenience methods for verifying whether map, set, list CQL type supported #1612

Open
tatu-at-datastax opened this issue Oct 28, 2024 · 0 comments

Comments

@tatu-at-datastax
Copy link
Contributor

(continuation of #1600 / #1451)

From @amorton :


we have this check for supported key types in a few places. Do you also have a check for supported value types ?
Do you have the same for the valueTypes for lists , sets, and vectors ?

if so can you put them public in places that make sense and I can call them from higher up when working out if we support the schema for a table

e.g. I have this in a PR for working out if we support the map schema for a table

public static boolean isCqlTypeSupported(MapType cqlMapType) {
  Objects.requireNonNull(cqlMapType, "cqlMapType must not be null");

  // cannot be frozen
  if (cqlMapType.isFrozen()) {
    return false;
  }
  // keys must be text or ascii, because keys in JSON are string
  if (!(cqlMapType.getKeyType() == DataTypes.TEXT
      || cqlMapType.getKeyType() == DataTypes.ASCII)) {
    return false;
  }
  // must be a primitive type value
  return cqlMapType.getValueType() instanceof PrimitiveType;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant