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

[sql expressions] fix: use ast to read tables (#87867) - backport #87875

Merged
merged 3 commits into from
May 15, 2024

Conversation

scottlepp
Copy link
Contributor

Backport to 11.0.x

  • [sql expressions] fix: use ast to read tables

  • can't run tests during ci yet. need to install duckdb

(cherry picked from commit 14a814a)

@scottlepp scottlepp added backport A backport PR no-changelog Skip including change in changelog/release notes labels May 14, 2024
@scottlepp scottlepp requested review from a team as code owners May 14, 2024 21:38
@scottlepp scottlepp requested review from zserge, mildwonkey and suntala and removed request for a team May 14, 2024 21:38
@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.0.x milestone May 14, 2024
@scottlepp scottlepp requested a review from ryantxu May 14, 2024 21:39
@scottlepp scottlepp requested review from toddtreece, samjewell and a team May 14, 2024 22:42
@ryantxu
Copy link
Member

ryantxu commented May 15, 2024

neat -- I tried SELECT json_serialize_sql('SELECT 1 + 2 FROM tbl1'); and the output is;

{
  "error": false,
  "statements": [
    {
      "node": {
        "type": "SELECT_NODE",
        "modifiers": [],
        "cte_map": {
          "map": []
        },
        "select_list": [
          {
            "class": "FUNCTION",
            "type": "FUNCTION",
            "alias": "",
            "query_location": 9,
            "function_name": "+",
            "schema": "",
            "children": [
              {
                "class": "CONSTANT",
                "type": "VALUE_CONSTANT",
                "alias": "",
                "query_location": 7,
                "value": {
                  "type": {
                    "id": "INTEGER",
                    "type_info": null
                  },
                  "is_null": false,
                  "value": 1
                }
              },
              {
                "class": "CONSTANT",
                "type": "VALUE_CONSTANT",
                "alias": "",
                "query_location": 11,
                "value": {
                  "type": {
                    "id": "INTEGER",
                    "type_info": null
                  },
                  "is_null": false,
                  "value": 2
                }
              }
            ],
            "filter": null,
            "order_bys": {
              "type": "ORDER_MODIFIER",
              "orders": []
            },
            "distinct": false,
            "is_operator": true,
            "export_state": false,
            "catalog": ""
          }
        ],
        "from_table": {
          "type": "BASE_TABLE",
          "alias": "",
          "sample": null,
          "query_location": 18,
          "schema_name": "",
          "table_name": "tbl1",
          "column_name_alias": [],
          "catalog_name": ""
        },
        "where_clause": null,
        "group_expressions": [],
        "group_sets": [],
        "aggregate_handling": "STANDARD_HANDLING",
        "having": null,
        "sample": null,
        "qualify": null
      }
    }
  ]
}

@scottlepp scottlepp requested a review from ryantxu May 15, 2024 10:48
@cletter7
Copy link
Contributor

Do we also need to add last commit to main?

@scottlepp scottlepp merged commit 39720ee into v11.0.x May 15, 2024
11 checks passed
@scottlepp scottlepp deleted the backport-87867-to-v11.0.x branch May 15, 2024 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend backport A backport PR no-changelog Skip including change in changelog/release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants