haeree
11/27/2026, 6:05 AMRocky
11/27/2026, 6:05 AMnative_query reference:
• It's a JDBC catalog table function: SELECT ... FROM TABLE(<jdbc_catalog>.native_query('<select_sql>')) [AS] alias
• Purpose: push SQL that's hard to express against a single JDBC external table (pre-filtered subqueries, source-side joins, vendor-specific syntax) down to the source database, then apply filters/joins/aggregations in StarRocks — or INSERT INTO the result.
• select_sql must be a string literal, must start with SELECT (after leading comments/trailing semicolons are stripped). WITH, INSERT, UPDATE, DELETE are not supported.
• Named arguments (query => ...) are not supported, and the legacy <catalog>.system.query(...) form is not supported.
• Column aliases after the table alias (AS q(c1, c2)) aren't supported — alias inside the SQL instead.
• Requires USAGE privilege on the JDBC catalog; source-side permission checks use the credentials configured in the catalog.
One caveat on my part: I couldn't find the specific release-note entry or PR that introduced it, so I can't tell you which exact 4.1.x patch first shipped it — only that the function reference says v4.1+. If you need the precise minimum patch version for your upgrade planning, check the release notes on the StarRocks GitHub releases page or ask in the community Slack.
References
• sql-reference/sql-functions/table-functions/native_query.md
• release_notes/release-4.1.md
• knowledge/known_issues/data_lake_external_catalog.md (StarRocks knowledge base)
• sql-reference/sql-functions/meta-functions/get_query_dump.md
• data_source/External_table.md
• sql-reference/sql-functions/SQL_UDF.mdhaeree
11/27/2026, 6:05 AMRocky
11/27/2026, 6:06 AMnative_query reference page in the StarRocks docs says "This function is supported from v4.1 onwards." That's the only source I have for the version claim.
What I can't verify:
• The labels on PR #72005 — I have no web access, so I can't read the PR, its labels, milestone, or which branches it was backported to.
• Whether that PR is the one that introduced native_query, or a follow-up change (docs, refactor, extension) to a function that landed earlier. A 4.2-only label is consistent with either "introduced in 4.2" or "an additional change targeting 4.2 only."
• Whether the docs version note is accurate for the code that actually shipped.
So my earlier "it already exists in 4.1" was based solely on the docs page, and I overstated my confidence. Given the PR label, the docs note may be ahead of the released branches, or the function may have been cherry-picked later than documented.
To settle it authoritatively, check:
1. The branch-4.1 FE source for the native_query table function class — if it's absent there and present on `main`/`branch-4.2`, the docs note is wrong.
2. The 4.1.x and 4.2 release notes on the GitHub releases page.
3. Ask in the StarRocks community Slack or on the PR itself — the PR author or reviewer can confirm the target release.
If you can paste the PR title/description or tell me what branch it targets, I can be more useful.
References
• sql-reference/sql-functions/table-functions/native_query.md
• data_source/catalog/jdbc_catalog.md
• release_notes/release-4.1.md
• knowledge/known_issues/data_lake_external_catalog.md (StarRocks knowledge base)
• data_source/External_table.md
• knowledge/known_issues/query.md (StarRocks knowledge base)