Skip to content

chore(c/validation): add quirk for identifier quoting#4504

Merged
lidavidm merged 1 commit into
apache:mainfrom
fornwall:validation/quote-identifier-quirk
Jul 14, 2026
Merged

chore(c/validation): add quirk for identifier quoting#4504
lidavidm merged 1 commit into
apache:mainfrom
fornwall:validation/quote-identifier-quirk

Conversation

@fornwall

Copy link
Copy Markdown
Contributor

Add a identifier quoting hook whose default reproduces the current ANSI double-quoted identifier quoting.

Existing drivers are unaffected - new drivers for databases not supporting double quotes for identifiers (such as GoogleSQL ones, which use backticks) can override the hook.

This mirrors what the adbc-drivers/driverbase-go validation harness does through its optional TableQuoter interface, which also defaults to ANSI double quotes.

@fornwall
fornwall requested a review from lidavidm as a code owner July 10, 2026 23:48
@fornwall
fornwall force-pushed the validation/quote-identifier-quirk branch from 09cf9d3 to ff91980 Compare July 11, 2026 00:05
Comment thread c/validation/adbc_validation_statement.cc
@fornwall
fornwall force-pushed the validation/quote-identifier-quirk branch from ff91980 to ed95572 Compare July 13, 2026 07:45
@fornwall

fornwall commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

How come we sometimes have .c_str() and sometimes not? (Maybe we should just bring in std::string_literals?)

The reason for c_str() here is that we're using the ADBC C API, as in AdbcStatementSetSqlQuery, which takes the query as const char*:

AdbcStatusCode AdbcStatementSetSqlQuery(struct AdbcStatement* statement,
                                        const char* query, struct AdbcError* error);

This contrasts to the validation suite internal functions, which is C++ and takes strings or string views.

Given that, I don't think std::string_literals would help here - that helps with reducing syntactic overhead for literals that should be strings (std::string("mystring") -> "mystring"s), but not the other way around.

One thing we could do here to perhaps reduce noice is extracting the query into a variable, like:

  ASSERT_THAT(AdbcStatementSetSqlQuery(
                  &statement,
                  ("SELECT * FROM " + quirks()->QuoteIdentifier("bulk_ingest") +
                   " ORDER BY " + quirks()->QuoteIdentifier("col") + " ASC NULLS FIRST")
                      .c_str(),
                  &error),
              IsOkStatus(&error));

->

  std::string query = ("SELECT * FROM " + quirks()->QuoteIdentifier("bulk_ingest") +
                   " ORDER BY " + quirks()->QuoteIdentifier("col") + " ASC NULLS FIRST");
  ASSERT_THAT(AdbcStatementSetSqlQuery(&statement, query.c_str(), &error),
              IsOkStatus(&error));

Should I do that here?

@lidavidm

Copy link
Copy Markdown
Member

ah you're right, I was scrolling too quickly and thought we were using it inside the concat instead of outside

@lidavidm

Copy link
Copy Markdown
Member

What I think I actually want is to upgrade to C++20 so we can use std::format but for now I think this is OK

@fornwall

Copy link
Copy Markdown
Contributor Author

What I think I actually want is to upgrade to C++20 so we can use std::format

It's probably a good time, right? Created #4506 for that.

I can update to use std::format after that transtion is done (but as you say, I think this one can be merged, and then the code can be updated once C++20 is in).

@fornwall
fornwall force-pushed the validation/quote-identifier-quirk branch 4 times, most recently from 432f431 to 0062798 Compare July 13, 2026 14:37
Add a identifier quoting hook whose default reproduces the current ANSI
double-quoted identifier quoting.

Existing drivers are unaffected - new drivers for databases not supporting
double quotes for identifiers (such as GoogleSQL ones, which use backticks)
can override the hook.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@fornwall
fornwall force-pushed the validation/quote-identifier-quirk branch from 0062798 to 8468c47 Compare July 13, 2026 14:53
@lidavidm
lidavidm merged commit 0ac3fde into apache:main Jul 14, 2026
87 checks passed
fornwall added a commit to fornwall/adbc-spanner that referenced this pull request Jul 14, 2026
…entifier quirk (#278)

Advance the C++ validation-suite pin from 1388615 to apache/arrow-adbc
main @ 9be02985. The only suite change in the delta is
apache/arrow-adbc#4504, which adds the DriverQuirks::QuoteIdentifier
hook and routes the previously hardcoded ANSI double-quoted identifiers
in the ingest/prepare readback and DDL statements through it.

SpannerQuirks now overrides the hook to GoogleSQL backticks, so
identifier quoting is no longer part of what keeps the EXCLUDED
ingest-readback / non-Spanner-DDL buckets excluded; the remaining
blockers (INT/TEXT no-PK DDL, the synthetic adbc_ingest_key column
surfaced by `SELECT *`, the INSERT arity in SqlPrepareUpdate*) are
re-documented in the bucket comments. No EXCLUDED entry changes: the
gate still runs 58 cases (52 pass, 6 self-skip) and the
expected-failure guard confirms all 42 excluded cases still fail or
skip on the new pin.

Also:
- Reword the CMakeLists pin comment: the C++ suite pin and the Rust
  adbc_core/adbc_ffi pin in Cargo.toml are the same family but bumped
  independently and may differ.
- Force arrow-adbc's from-source googletest fallback
  (CMAKE_DISABLE_FIND_PACKAGE_GTest): an installed GTest config package
  (e.g. linuxbrew) is directory-scoped to the fetched subproject and
  broke the top-level target_link_libraries, and hermetic from-source
  is the suite's stated design anyway.
- Fix stale counts in adbc-validation/README.md (42 excluded / 58
  gate-enforced, not 45 / 55).


Claude-Session: https://claude.ai/code/session_01Ao7MRWDTdb3rdgN9kWBf3e

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@lidavidm lidavidm added this to the ADBC Libraries 24 milestone Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants