Skip to content

Index creation on map $keys sensitive to mere presence of options object in index definition #2524

Description

@sl-at-ibm

Summary: the configuration of an index on $keys for a map column depends on whether the definition.options part is in the payload or not.

Expectation: a main Data API tenet is that in payloads you can pass a certain field with (a) null value, (b) empty-object value, and (c) omit that field altogether, and ==> not observe any difference in the results. This case violates that expectation.

Details

Say you have a table, e.g.

{
    "createTable": {
        "name": "ttg",
        "definition": {
            "columns": {
                "a": "text",
                "t": {
                    "type": "map",
                    "keyType": "text",
                    "valueType": "text"
                }
            },
            "primaryKey": {
                "partitionBy": [
                    "a"
                ],
                "partitionSort": {}
            }
        }
    }
}

Now you can create the index like this (PAYLOAD A):

{
    "createIndex": {
        "definition": {
            "column": {
                "t": "$keys"
            },
            "options": {
                "caseSensitive": null,
                "normalize": null,
                "ascii": null
            }
        },
        "options": {
            "ifNotExists": null
        },
        "name": "idx_ttg_t"
    }
}

Or this (PAYLOAD B):

{
    "createIndex": {
        "definition": {
            "column": {
                "t": "$keys"
            },
            "options": {}
        },
        "options": {
            "ifNotExists": null
        },
        "name": "idx_ttg_t"
    }
}

Or this (PAYLOAD C):

{
    "createIndex": {
        "definition": {
            "column": {
                "t": "$keys"
            }
        },
        "options": {
            "ifNotExists": null
        },
        "name": "idx_ttg_t"
    }
}

A = individual values passed as null
B = empty-object 'options'
C = no 'options' at all.

Experimentally, it turns out A and B result in the Data API supplying its hardcoded defaults (namely, caseSensitive=true, normalize=false, ascii=false), while C result in no configuration being written at all.
(As reported by listIndexes(explain=true))

Expectation

One would expect A, B and C to result in the same index config.
(which one? To me no settings seems the most reasonable thing to do, i.e. what now happens with payload C).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions