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

API support for case-(in)sensitive table names #1369

Merged
merged 9 commits into from
Feb 13, 2024
Merged

Conversation

ryzhyk
Copy link
Contributor

@ryzhyk ryzhyk commented Feb 1, 2024

Previously our API insisted on referring to tables and views in upper case.
This manifested in two places: /ingress/TABLE_NAME and /egress/VIEW_NAME
API endpoints and in connection configuration, where the user must specify
table or view name.

In this commit we remove this limitation and allow relations to be addressed
using any case. More specifically:

  • Case-insensitive relation names, i.e., relations declared without
    quotes in SQL, can be addressed in UPPERCASE, lowercase, or MiXeD
    CaSe, e.g.,
    /ingress/TABLE, /ingress/table, and /ingress/TaBlE are all
    accepted.

  • Case-sensitive relations declared with quotes, e.g.,
    create table "Foo"(...) or create view "BAR" as ... must be
    addressed in the same case as their declaration by putting their
    names in quotes: /ingress/"Foo", /egress/"BAR".

Addresses issue #51.

Is this a user-visible change (yes/no): yes

@ryzhyk
Copy link
Contributor Author

ryzhyk commented Feb 1, 2024

@Karakatiza666 , I need your help wrapping up this PR. It requires referring to case-sensitive relation names in quotes in the API, including /ingress and /egress endpoints and connector config.

@ryzhyk ryzhyk linked an issue Feb 1, 2024 that may be closed by this pull request
4 tasks
@ryzhyk ryzhyk added this to the Feb 6 2024 milestone Feb 1, 2024
@ryzhyk ryzhyk added Web Console Related to the browser based UI adapters Issues related to the adapters crate UX Issues that effect an end-user's experience labels Feb 1, 2024
name.to_lowercase()
};

self.input_collection_handles.insert(name, handle);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this fail?
does this overwrite a previously existing name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, there's no checking for duplicates at the moment. I'll add that.

crates/pipeline-types/src/program_schema.rs Show resolved Hide resolved
crates/adapters/src/catalog.rs Show resolved Hide resolved
crates/pipeline_manager/src/db/pipeline.rs Outdated Show resolved Hide resolved

/// A SQL table or view. It has a name and a list of fields.
///
/// Matches the Calcite JSON format.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calcite or SQL compiler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't write this comment, but I'm pretty sure it's the SQL compiler.

/// - `VARCHAR(255)` sets precision to `255`.
/// - `BIGINT`, `DATE`, `FLOAT`, `DOUBLE`, `GEOMETRY`, etc. sets precision
/// to None
/// - `TIME`, `TIMESTAMP` set precision to `0`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong, I think that Calcite only works with precision "3" for TIMESTAMP.
Maybe this is a bug we should look into.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied this code into a different location, haven't touched it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the time, I verified this by manually creating these types and see what I get back from the compiler

crates/pipeline_manager/src/db/pipeline.rs Outdated Show resolved Hide resolved
crates/pipeline_manager/src/db/pipeline.rs Outdated Show resolved Hide resolved
@ryzhyk ryzhyk force-pushed the case-insensitive-tables branch 2 times, most recently from 8929ad2 to 655a0ab Compare February 2, 2024 07:41
Leonid Ryzhyk and others added 8 commits February 12, 2024 16:42
Upcoming commits will use these types in the `adapters` crate, which
will need to manipulate program schema.

Signed-off-by: Leonid Ryzhyk <leonid@feldera.com>
This field was added a while ago by the compiler, but hasn't been used.
We are going to start using it in an upcoming commit.

Signed-off-by: Leonid Ryzhyk <leonid@feldera.com>
The SQL compiler now passes SQL table schema descriptions in the JSON
format when registering tables and views in the catalog.  Upcoming
commits make use of the schema in two ways:

1. Extract case sensitivity information from the schema in order
   to correctly handle table names in API calls and in pipeline
   configuration.

2. Use the schema to generate table schema for data formats that
   require it (initially, Kafka Connect's JSON format).

Signed-off-by: Leonid Ryzhyk <leonid@feldera.com>
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
This column was recently added by the compiler.

Signed-off-by: Leonid Ryzhyk <leonid@feldera.com>
Previously our API insisted on referring to tables and views in upper case.
This manifested in two places: `/ingress/TABLE_NAME` and `/egress/VIEW_NAME`
API endpoints and in connection configuration, where the user must specify
table or view name.

In this commit we remove this limitation and allow relations to be addressed
using any case.  More specifically:
- Case-insensitive relation names, i.e., relations declared without
  quotes in SQL, can be addressed in UPPERCASE, lowercase, or MiXeD
  CaSe, e.g.,
  `/ingress/TABLE`, `/ingress/table`, and `/ingress/TaBlE` are all
  accepted.

- Case-sensitive relations declared with quotes, e.g.,
  `create table "Foo"(...)` or `create view "BAR" as ...` must be
  addressed in the same case as their declaration by putting their
  names in quotes: `/ingress/"Foo"`, `/egress/"BAR"`.

Addresses issue #51.

Signed-off-by: Leonid Ryzhyk <leonid@feldera.com>
Signed-off-by: George <bulakh.96@gmail.com>
Signed-off-by: George <bulakh.96@gmail.com>
@ryzhyk ryzhyk marked this pull request as ready for review February 13, 2024 17:12
@ryzhyk ryzhyk merged commit 8e9eebe into main Feb 13, 2024
5 checks passed
@ryzhyk ryzhyk deleted the case-insensitive-tables branch February 13, 2024 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adapters Issues related to the adapters crate UX Issues that effect an end-user's experience Web Console Related to the browser based UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Make Catalog API case-insensitive.
5 participants