Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-19560

Implement support for virtual types

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Normal
    • Resolution: Unresolved
    • 5.x
    • Feature/Virtual Tables
    • None
    • Operability
    • Normal
    • All
    • None

    Description

      We can not use user types in virtual tables. While it might look strange at first to ask for the support of this, currently we can not do something like this:

      cqlsh> select * from system_guardrails.thresholds ;
      
       name                          | value
      -------------------------------+----------------------
                     collection_size |   {warn: 0, fail: 0}
                   column_value_size | {warn: -1, fail: -1}
                   columns_per_table | {warn: -1, fail: -1}
      ...
      
      VIRTUAL TABLE system_guardrails.thresholds (
          name text PRIMARY KEY,
          value settings
      ) WITH comment = 'Guardrails configuration table for thresholds';
      

      because "settings" is a UDT

      cqlsh> DESCRIBE type system_guardrails.settings ;
      
      CREATE TYPE system_guardrails.settings (
          warn bigint,
          fail bigint
      );
      

      While this is not absolutely necessary to implement and it might be worked around by a simple tuple, it feels sad that user experience suffers. Supporting custom types for vtables is indeed possible so we should just do that.

      There is additional work needed to do this, because virtual types are not supported in python-driver, I had to do this:

      https://github.com/smiklosovic/python-driver/commit/14b236bb471bc4a7e251a9f6b694de7885b339de

      python-driver reads system_schema.types in order to show the correct output in cqlsh, as it has not recognized virtual types, it was always displaying the results like

      settings(warn=-1, fail -1)
      

      because it could not evaluate it differently.

      With the patch for python-driver, it will fetch it from system_virtual_schema.types, where it will be like:

      cqlsh> select * from system_virtual_schema.types ;
      
       keyspace_name     | type_name | field_names      | field_types
      -------------------+-----------+------------------+----------------------
       system_guardrails |  settings | ['warn', 'fail'] | ['bigint', 'bigint']
      
      (1 rows)
      

      Attachments

        Issue Links

          Activity

            People

              smiklosovic Stefan Miklosovic
              smiklosovic Stefan Miklosovic
              Stefan Miklosovic
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: