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 support for hybrid index ddl #737

Merged
merged 2 commits into from
Jun 17, 2021
Merged

Add support for hybrid index ddl #737

merged 2 commits into from
Jun 17, 2021

Conversation

chuan
Copy link
Contributor

@chuan chuan commented Jun 15, 2021

After some discussion with @daxhaw, we have settled on the "CREATE RELATIONSHIP ... USING" for hybrid index DDL. To create a relationship with hybrid index, users need to add the optional "USING" clause at the end of the "CREATE RELATIONSHIP" statement. Here is an example:

CREATE RELATIONSHIP return_flight_passenger (
  flight.return_passengers -> passenger[],
  passenger.return_flight -> flight,
  USING passenger(return_flight_number), flight(number)
);

Copy link
Contributor

@senderista senderista left a comment

Choose a reason for hiding this comment

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

LGTM, couple nits. (I also really like the USING syntax.)

production/catalog/parser/src/parser.yy Outdated Show resolved Hide resolved
@@ -503,6 +512,13 @@ struct create_relationship_t : create_statement_t
// A relationship is defined by a pair of links because we only allow
// bi-directional relationships.
std::pair<link_def_t, link_def_t> relationship;

// Track the optional mapping from one table's field(s) to the other table's
// field(s). The field map must be bijective or have 1:1 correspondence from
Copy link
Contributor

Choose a reason for hiding this comment

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

"bijective or 1:1" is a little confusing since they're synonymous.

Copy link
Contributor

Choose a reason for hiding this comment

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

Though it makes sense for those that knew them before they were synonymous. ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually now that I think about it, "1:1" is ambiguous between "injective" and "bijective" (I think I've seen it used in both senses in math).

production/inc/gaia_internal/catalog/catalog.hpp Outdated Show resolved Hide resolved
{
parser_t parser;

const string create_relationship_ddl = R"(
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know C++ had raw strings, this is really useful!

Copy link

@yiwen-wong yiwen-wong left a comment

Choose a reason for hiding this comment

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

Other than the typo pointed out by Tobin LGTM

Copy link
Contributor

@simone-gaia simone-gaia left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -503,6 +512,12 @@ struct create_relationship_t : create_statement_t
// A relationship is defined by a pair of links because we only allow
// bi-directional relationships.
std::pair<link_def_t, link_def_t> relationship;

// Track the optional mapping from one table's field(s) to the other table's
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: the mapping is required to specify a hybrid index, right? I can't create a hybrid index without the mapping, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is optional in the sense the relationship can still be created with gaia_id without the USING clause.

@chuan chuan merged commit 930ec34 into master Jun 17, 2021
@chuan chuan deleted the hybrid-index-ddl branch June 17, 2021 16:33
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

Successfully merging this pull request may close these issues.

6 participants