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

The {{ workingDir }} is not rendered correctly in DuckDB Query task when the query is passed from a SQL file stored as a namespace file #300

Open
anna-geller opened this issue May 7, 2024 · 0 comments
Assignees
Labels
area/plugin Plugin-related issue or feature request bug Something isn't working

Comments

@anna-geller
Copy link
Member

anna-geller commented May 7, 2024

Expected Behavior

Ideally, the {{ workingDir }} should not be needed. Given that the file is passed as part of inputFiles, you shouldn't need that workingDir part here:

INSTALL json;
LOAD json;
SELECT brand, round(avg(price), 2) as avg_price
FROM read_json_auto('{{ workingDir }}/products.json')
GROUP BY brand
ORDER BY avg_price DESC;

image

reproducer:

id: myflow
namespace: myteam

inputs:
  - id: columns_to_keep
    type: STRING
    defaults: |-
      ["brand", "price"]

tasks:
  - id: extract
    type: io.kestra.plugin.fs.http.Download
    uri: https://dummyjson.com/products

  - id: transform
    type: io.kestra.plugin.scripts.python.Commands
    containerImage: python:3.11-alpine
    inputFiles:
      data.json: "{{ outputs.extract.uri }}"
    outputFiles:
      - "*.json"
    env:
      COLUMNS_TO_KEEP: "{{ inputs.columns_to_keep }}"
    namespaceFiles:
      enabled: true
    commands:
      - python scripts/main.py

  - id: query
    type: io.kestra.plugin.jdbc.duckdb.Query
    inputFiles:
      products.json: "{{ outputs.transform.outputFiles['products.json'] }}"
    sql: |
      INSTALL json;
      LOAD json;
      SELECT brand, round(avg(price), 2) as avg_price
      FROM read_json_auto('{{ workingDir }}/products.json')
      GROUP BY brand
      ORDER BY avg_price DESC;
    store: true

  - id: query_fail
    type: io.kestra.plugin.jdbc.duckdb.Query
    inputFiles:
      products.json: "{{ outputs.transform.outputFiles['products.json'] }}"
    sql: "{{ read('query.sql')}}"
    store: true

Actual Behaviour

No response

Steps To Reproduce

No response

Environment Information

  • Kestra Version: develop
  • Plugin version:
  • Operating System (OS / Docker / Kubernetes):
  • Java Version (If not docker):

Example flow

No response

@anna-geller anna-geller added the bug Something isn't working label May 7, 2024
@anna-geller anna-geller added this to the v0.18.0 milestone May 7, 2024
@github-project-automation github-project-automation bot moved this to Backlog in Issues Jun 10, 2024
@anna-geller anna-geller removed this from the v0.18.0 milestone Jul 8, 2024
@anna-geller anna-geller added the area/plugin Plugin-related issue or feature request label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugin Plugin-related issue or feature request bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

2 participants