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

Support column_list in CONTAINS #3438

Conversation

jaspal007
Copy link

Description

Specifies two or more columns, separated by commas. column_list must be enclosed in parentheses. Unless language_term is specified, the language of all columns of column_list must be the same.

Issues

Previously Babelfish did not support syntax for multiple columns for simple terms in contains clause, as a result it was not configured to run the CONTAINS clause queries that required multiple columns.

  • To fix this issue we have to change the way babelfish accepts the column list and then implement a way to rewrite those multiple columns into a way PostgreSQL can process.

syntax for multiple columns in TSQL

SELECT * FROM table_name WHERE CONTAINS((column_list), <predicate>)
GO

Now this syntax needs to be rewritten as a PostgreSQL query

SELECT * FROM table_name WHERE to_tsvector('configuration', column1||' '""column2||' '||...) @@
to_tsquery('configuration', <predicate>)
  • Previously at the entry point of where the TSQL queries were written, the sys.replace_special_chars_fts function accepted only one column as an argument of type text which caused following issue
image

Changes to fix the issues

  • Made the TSQL syntax identifiable in Babelfish, by adding the rule in gram-tsql-rule.y for CONTAINS clause.
  • Fixed the entry point issue, by changing the sys.replace_special_chars_fts function declaration to accept variable number of columns as arguments by using Postgres keyword VARIADIC
  • Changed the declaration of TsqlExpressionContains and makeToTSVectorFuncCall to accept the passed list of columns.

Task: BABEL-4239
Authored-by: Jaspal Singh [email protected]
Signed-off-by: Jaspal Singh [email protected]

Issue resolved

BABEL-4239
Engine side PR link: Support column_list in CONTAINS #521

Test Scenarios Covered

Use case based -

Boundary conditions -

Arbitrary inputs -

Negative test cases -

Minor version upgrade tests -

Major version upgrade tests -

Performance tests -

Tooling impact -

Client tests -

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

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.

1 participant