You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Michael J. Carey (Jira)" <ji...@apache.org> on 2024/09/20 15:44:00 UTC

[jira] [Created] (ASTERIXDB-3506) CREATE TYPE needs to support a union type notation

Michael J. Carey created ASTERIXDB-3506:
-------------------------------------------

             Summary: CREATE TYPE needs to support a union type notation
                 Key: ASTERIXDB-3506
                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-3506
             Project: Apache AsterixDB
          Issue Type: Improvement
          Components: *DB - AsterixDB, COMP - Compiler, MTD - Metadata, SQL - Translator SQL++, TYPE - Data Model
    Affects Versions: 0.9.9
            Reporter: Michael J. Carey
             Fix For: 0.9.9


Suppose you had the following CREATE TYPE statement:

CREATE TYPE productsType AS {
    itemno: int,
    category: string,
    name: string,
    descrip: string?,
    manuf: string,
    listprice: int
};

If for some (perhaps ill-advised) reason you wanted to permit the listprice field to be either an int or a string, we have no way to express that at present.  We need a notation that addresses that!  E.g., something along the following lines (final syntax TBD):

CREATE TYPE productsType AS {
    itemno: int,
    category: string,
    name: string,
    descrip: string?,
    manuf: string,
    listprice: int | string
};

Note that internally the schema inference under our columnar format can represent this, there's just no way to say it at the user level.  Note that we'd also have to extend the check-before-deposit logic in INSERT and UPSERT to enforce these sorts of more general type constraints - not sure if it would "just work" or if it's significant new code (since I haven't looked at that part of the code base).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)