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 table identifier contains dot with backticks #768

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

LantaoJin
Copy link
Member

@LantaoJin LantaoJin commented Oct 11, 2024

Description

Table name `_CWLBasic`.default.`Canary/service.log` is incorrectly converted to default + Canary/service + log.

It should be converted to _CWLBasic + default + Canary/service.log as long as the table identifier is wrapped by backticks.

Issues Resolved

#767

Check List

  • Updated documentation (ppl-spark-integration/README.md)
  • Implemented unit tests
  • Implemented tests for combination with other commands
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@LantaoJin LantaoJin added the 0.6 label Oct 11, 2024
Signed-off-by: Lantao Jin <[email protected]>
test("test describe FQN table clause") {
val context = new CatalystPlanContext
val logPlan =
planTransformer.visit(plan(pplParser, "describe schema.default.http_logs"), context)
planTransformer.visit(plan(pplParser, "describe catalog.schema.http_logs"), context)
Copy link
Member Author

Choose a reason for hiding this comment

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

This PR also fixes a bug of describe command.
The pattern catalog.schema.table will be converted to
TableIdentifier(table, Some(schema), Some(catalog))
Without patch, it was TableIdentifier(table, Some(catalog), Some(schema))

Copy link
Member Author

@LantaoJin LantaoJin Oct 11, 2024

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@LantaoJin nice catch - thanks

@LantaoJin LantaoJin marked this pull request as ready for review October 11, 2024 07:38
Comment on lines +162 to +164
node.getQualifiedNames().forEach(q ->
// Resolving the qualifiedName which is composed of a datasource.schema.table
context.withRelation(new UnresolvedRelation(seq(of(t.split("\\."))), CaseInsensitiveStringMap.empty(), false))
context.withRelation(new UnresolvedRelation(getTableIdentifier(q).nameParts(), CaseInsensitiveStringMap.empty(), false))
Copy link
Member Author

@LantaoJin LantaoJin Oct 11, 2024

Choose a reason for hiding this comment

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

These are the key lines to fix the bug of "dot in backticks"

Copy link
Member Author

@LantaoJin LantaoJin Oct 11, 2024

Choose a reason for hiding this comment

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

Replace simple string manipulation with building a Spark TableIdentifier. This fixing not only could identify a valid pattern catalog.schema.`table.name`, but also could identify an invalid pattern catalog.schema.table.name (more than 3 parts and without backticks)

Copy link
Member

@YANG-DB YANG-DB left a comment

Choose a reason for hiding this comment

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

@LantaoJin thanks for the quick fix !!

@YANG-DB YANG-DB merged commit fe5148c into opensearch-project:main Oct 11, 2024
4 checks passed
@opensearch-trigger-bot
Copy link

The backport to 0.5 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/opensearch-spark/backport-0.5 0.5
# Navigate to the new working tree
pushd ../.worktrees/opensearch-spark/backport-0.5
# Create a new branch
git switch --create backport/backport-768-to-0.5
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 fe5148cb4968917e532a1ddd745a80d4f58e576b
# Push it to GitHub
git push --set-upstream origin backport/backport-768-to-0.5
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/opensearch-spark/backport-0.5

Then, create a pull request where the base branch is 0.5 and the compare/head branch is backport/backport-768-to-0.5.

@opensearch-trigger-bot
Copy link

The backport to 0.5-nexus failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/opensearch-spark/backport-0.5-nexus 0.5-nexus
# Navigate to the new working tree
pushd ../.worktrees/opensearch-spark/backport-0.5-nexus
# Create a new branch
git switch --create backport/backport-768-to-0.5-nexus
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 fe5148cb4968917e532a1ddd745a80d4f58e576b
# Push it to GitHub
git push --set-upstream origin backport/backport-768-to-0.5-nexus
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/opensearch-spark/backport-0.5-nexus

Then, create a pull request where the base branch is 0.5-nexus and the compare/head branch is backport/backport-768-to-0.5-nexus.

@seankao-az seankao-az added Lang:PPL Pipe Processing Language support and removed backport 0.5 labels Oct 11, 2024
@seankao-az
Copy link
Collaborator

Backport to 0.5-nexus failed. Manually backporting

@seankao-az
Copy link
Collaborator

Found some other missing commits due to backport failure of other PR, e.g. #743

@opensearch-trigger-bot
Copy link

The backport to 0.5 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/opensearch-spark/backport-0.5 0.5
# Navigate to the new working tree
pushd ../.worktrees/opensearch-spark/backport-0.5
# Create a new branch
git switch --create backport/backport-768-to-0.5
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 fe5148cb4968917e532a1ddd745a80d4f58e576b
# Push it to GitHub
git push --set-upstream origin backport/backport-768-to-0.5
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/opensearch-spark/backport-0.5

Then, create a pull request where the base branch is 0.5 and the compare/head branch is backport/backport-768-to-0.5.

YANG-DB added a commit to YANG-DB/opensearch-spark that referenced this pull request Oct 11, 2024
seankao-az pushed a commit that referenced this pull request Oct 12, 2024
…icks (#774)

* backport #768 to 0.5-nexus

Signed-off-by: YANGDB <[email protected]>

* support spark prior to 3.5 with its extended table identifier (existing table identifier only has 2 parts)

Signed-off-by: YANGDB <[email protected]>

---------

Signed-off-by: YANGDB <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants