Skip to content

CADC-15541: Youcat: update table-ops to match ops WD - #267

Open
aratikakadiya wants to merge 6 commits into
opencadc:v1.1-nextfrom
aratikakadiya:tap-next
Open

aratikakadiya wants to merge 6 commits into
opencadc:v1.1-nextfrom
aratikakadiya:tap-next

Conversation

@aratikakadiya

Copy link
Copy Markdown
Contributor
  • Added support for multicolumn index -- updated params structure according to the openapi doc.
  • Added int test to test unique and multicolumn index with latest param structure.

- Added support for multicolumn index
- Added int test to test unique and multicolumn index with latest param structure.

@brianmajor brianmajor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I took a quick look and generally the code looks quite well constructed. I like how you plan to transition to the multi-column index by just throwing the UnsupportedOperationException for now, but having the framework in place. I will leave this to @pdowler to complete the merge when ready.

Updated int test to validate index creation success for long-lat index type and failure for x-y index type.

doCreateIndex(schemaOwner, tableName, List.of("c1", "c2"), null, "long-lat", ExecutionPhase.COMPLETED, null);
doCreateIndex(schemaOwner, tableName, List.of("c1", "c2"), null, "x-y", ExecutionPhase.ERROR,
"unexpected failure: failed to update table int_test_schema.testCreateMultiColIndex reason: x-y index type is not yet supported");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if the response to this test starts with "unexpected failure" then we should fix that to actually output something like "unsupported: x-y index type".

normally, UnsupportedOperationException is used for things we have not implemented. iirc, both IllegalArgumentException and UOE map to 400 so on the client side of http our code maps them both to IllegalArgumentException (aka bad request)... so will take some care to make the reported message be correct.

aside: it was probably a bad idea to have two different thrown exceptions map to the same http code (400) but there is still a lot of code that does it.

sb.append(" USING ").append(using);
sb.append(" INDEX ").append(indexName);
sb.append(" ON ").append(first.getTableName());
if (indexType != null && (indexType.equalsIgnoreCase("long-lat") || indexType.equalsIgnoreCase("x-y"))) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All the index-type values must be passed to ddType.getIndexUsingQualifier(...) to the PG-specific code can generate the USING (or not). So the correct thing is to change the method signature of that method from (ColumnDesc, boolean) to (List, List) and fix the PG implementation.

if (iop != null) {
sb.append(" ").append(iop);

if (indexType != null && indexType.equalsIgnoreCase("long-lat")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

like above, but not that we have multi-column indixes we need to replace line 376-379 with a call to ddType to generate the expression (because it is PG-specific).

That means modifying the DatabaseDataType interface, maybe to combine these variable things?? We can rely on

CREATE [UNIQUE] INDEX <name> on <table_name> ...

but it seems like everything else could be backend specific. Maybe

String getIndexExpression(List<ColumnDesc> columns, List<String> indexTypes)

which has to return the ( ... ) and anything else that is needed. The default implementation (for no indexTypes) in BasicDataTypeMapper could just do the plain list of columns). I think this single method could make both getIndexUsingQualifier and getIndexColumnOperator obsolete.

return sb.toString();
}

private static String buildSpointExpression(List<ColumnDesc> columns, ColumnDesc column) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this belongs in the cadc-tap-server-pg` library

- Moved DB specific functionalities to the DatabaseDataType impls.
- Refactored the DatabaseDataType.java
- fixed issue with an error message for unsupported operations.
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.

3 participants