GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: Allow OUTER keyword as function parameter name by mountaincrab · Pull Request #2021 · JSQLParser/JSqlParser

Conversation

@mountaincrab

@mountaincrab mountaincrab commented Jun 14, 2024

Copy link
Copy Markdown
Contributor

Context

SQL keywords are sometimes allowed as parameter names in table functions. For example, the following statement is valid on Snowflake:

INSERT INTO db.schema.target
    (Name, FriendParent)
SELECT
    i.DATA_VALUE:Name AS Name,
    f1.Value:Parent:Name AS FriendParent
FROM
    db.schema.source AS i,
    flatten(input => i.DATA_VALUE:Friends, outer => true) AS f1

Note that the second named parameter passed to the table function flatten is outer, which is a SQL keyword, and it is unquoted.

Currently, statements like this fail to parse, I think because SQL keywords are not allowed as parameter names. However, as this is a valid statement, I'd like to be able to parse it.

Details

The production in the grammar which handles named parameters is OracleNamedFunctionParameter. Currently, this is using the RelObjectNameExt2 production to match the parameter name. I think (although I don't understand how) this does not match keywords. Since parameter names are not objects, I thought we could use the <S_IDENTIFIER> token, which looks like it should match something like outer. However, this doesn't appear to match keywords, again I don't understand how - looking at the <S_IDENTIFIER> token, it looks like it will match any sequence of unicode characters 🤔 . As a simple (probably wrong) solution, I've manually added the <K_OUTER> token as a possible match in OracleNamedFunctionParameter:

( name=RelObjectNameExt2() | token=<K_OUTER> )

But this feels wrong. I don't think parameter names necessarily need to be valid object names, hence why I wanted to use <S_IDENTIFIER>, but I can't work out why <S_IDENTIFIER> won't match keywords. Happy to discuss this further, any help would be much appreciated!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

davidjgoss reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@mountaincrab
feat: Allow OUTER keyword as function parameter name
72fab91
@manticore-projects

manticore-projects commented Jun 14, 2024

Copy link
Copy Markdown
Contributor

Thank you for your contribution, very clean and efficient.
Please resolve the QA exceptions on formatting and I will merge,

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mountaincrab

mountaincrab commented Jun 14, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Thank you for your contribution, very clean and efficient. Please resolve the QA exceptions on formatting and I will merge,

Thanks for the speedy response @manticore-projects 😁 I just wanted to double check you're happy with the solution. As explained in the PR description, I don't think it's ideal! I feel like we could do it a better way e.g. just using <S_IDENTIFIER>, but I'm not quite sure how...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects

manticore-projects commented Jun 14, 2024

Copy link
Copy Markdown
Contributor

Thank you for your contribution, very clean and efficient. Please resolve the QA exceptions on formatting and I will merge,

Thanks for the speedy response @manticore-projects 😁 I just wanted to double check you're happy with the solution. As explained in the PR description, I don't think it's ideal! I feel like we could do it a better way e.g. just using <S_IDENTIFIER>, but I'm not quite sure how...

I know its not ideal, but it is efficient and fixes the problem right now while maintaining the options for improving it later.
The real solution was another production AllowedFunctionArgumentTokens, derived from RelObjectNameExt2 and adding the extra tokens there. But that takes time to do properly.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mountaincrab

mountaincrab commented Jun 14, 2024

Copy link
Copy Markdown
Contributor Author

OK sounds good, as long as you're happy 😁 Will get the formatting sorted 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mountaincrab
chore: Spotless
c58f128
@mountaincrab
mountaincrab marked this pull request as ready for review June 14, 2024 14:35
@mountaincrab

mountaincrab commented Jun 14, 2024

Copy link
Copy Markdown
Contributor Author

That should be all sorted now!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects
manticore-projects merged commit fc90c0b into JSQLParser:master Jun 14, 2024
@manticore-projects

manticore-projects commented Jun 14, 2024

Copy link
Copy Markdown
Contributor

Thank you again for your contribution!

mountaincrab reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@mountaincrab @manticore-projects
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.