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

[Enhancement] Append lookup table field to a new output field in LOOKUP command will fail #1040

Open
LantaoJin opened this issue Feb 8, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@LantaoJin
Copy link
Member

LantaoJin commented Feb 8, 2025

Is your feature request related to a problem?

In docs/ppl-lang/ppl-lookup-command.md

outputField

  • Optional
  • Default: <inputField>
  • Description: A field of output. You can specify zero or multiple <outputField>. If you specify <outputField> with an existing field name in source query, its values will be replaced or appended by matched values from <inputField>. If the field specified in <outputField> is a new field, in REPLACE strategy, an extended new field will be applied to the results, but fail in APPEND strategy.

Demo

  • fact table
id col1 col2
1 a b
2 aa bb
3 null ccc
  • dimension table
id col1 col3
1 x y
3 xx yy

Replace lookup table field to a new output field:

Q1: source=fact | lookup dim id REPLACE col1 as colA

An extended new field colA will be applied to the results

id col1 col2 colA
1 a b x
2 aa bb null
3 null ccc xx

Append lookup table field to a new output field:

Q2: source=fact | lookup dim id APPEND col1 as colA

Throws with "A column or function parameter with name colA cannot be resolved"

Actually, as the colA is a new field which not existed in fact and dim, the Q2 could be rewritten by Q1.

More complexity, for query

Q3: source=fact | lookup dim id APPEND col1, col3 as colA

could be rewritten to

Q4: source=fact | lookup dim id APPEND col1 | lookup dim id REPLACE col3 as colA

What solution would you like?
The failure is because the current implementation Coalesce expression cannot be resolved with a not existed attribute. To resolve the failure of query Q2 and Q3, we have to extract the output attributes from source plan (not source table).

What alternatives have you considered?
Keep throwing failure since the failed Q2 and Q3 can be rewritten to Q1 and Q4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant