Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/include/yardstick_extension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,25 @@ class YardstickExtension : public Extension {
BoundStatement yardstick_bind(ClientContext &context, Binder &binder,
OperatorExtensionInfo *info, SQLStatement &statement);

// DuckDB main changed parse_function_t to receive the post-PEG-failure token
// tail (vector<SimpleToken>) instead of the raw query string; DuckDB 1.5 and
// earlier pass the query string. Detected via the header the refactor introduced.
// Yardstick performs all of its rewriting in yardstick_parser_override (which
// still receives the full query string on both APIs), so on the new signature
// parse_function is a no-op fallback.
#if __has_include("duckdb/common/identifier.hpp")
#define YARDSTICK_TOKEN_PARSE_FN 1
#else
#define YARDSTICK_TOKEN_PARSE_FN 0
#endif

#if YARDSTICK_TOKEN_PARSE_FN
ParserExtensionParseResult yardstick_parse(ParserExtensionInfo *,
const vector<SimpleToken> &tokens);
#else
ParserExtensionParseResult yardstick_parse(ParserExtensionInfo *,
const std::string &query);
#endif

ParserExtensionPlanResult yardstick_plan(ParserExtensionInfo *, ClientContext &,
unique_ptr<ParserExtensionParseData>);
Expand Down
11 changes: 11 additions & 0 deletions src/yardstick_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ static bool StartsWithSemantic(const std::string &query, std::string &stripped_q
return true;
}

#if YARDSTICK_TOKEN_PARSE_FN
// DuckDB main: parse_function receives the post-PEG-failure token tail rather
// than the query string. Yardstick rewrites queries earlier, in
// yardstick_parser_override (which sees the full query string), so there is
// nothing to do here -- decline and let DuckDB proceed.
ParserExtensionParseResult yardstick_parse(ParserExtensionInfo *,
const vector<SimpleToken> &) {
return ParserExtensionParseResult();
}
#else
ParserExtensionParseResult yardstick_parse(ParserExtensionInfo *,
const std::string &query) {

Expand Down Expand Up @@ -422,6 +432,7 @@ ParserExtensionParseResult yardstick_parse(ParserExtensionInfo *,
// Not a yardstick query, let DuckDB handle it
return ParserExtensionParseResult();
}
#endif // YARDSTICK_TOKEN_PARSE_FN

//=============================================================================
// PARSER OVERRIDE: intercepts ALL queries before DuckDB's native parser
Expand Down
Loading
Loading