Skip to content

chore(bigquery-jdbc): update perf client to run custom queries#13521

Open
logachev wants to merge 1 commit into
mainfrom
kirl/perf_client_extras
Open

chore(bigquery-jdbc): update perf client to run custom queries#13521
logachev wants to merge 1 commit into
mainfrom
kirl/perf_client_extras

Conversation

@logachev

Copy link
Copy Markdown
Contributor

Allow specifying custom queries via cmd-line or file for perf client

@logachev logachev requested review from a team as code owners June 18, 2026 21:09

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for executing SQL queries from a file (--query-file) across the JDBC client, performance runner, and associated Makefiles, alongside updating the documentation. The review feedback suggests resolving the query file to an absolute path and validating its existence early in the Python performance runner to prevent subprocess path resolution issues. Additionally, it recommends using the base name of the query file in the performance results markdown to keep columns concise, and adding a validation check in the Java client to prevent executing empty or blank queries.

Comment on lines +241 to +244
query = args.query
query_file = args.query_file
generate_rows = args.generate_rows
generate_cols = args.generate_cols

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

To ensure that relative paths for --query-file are resolved correctly regardless of the working directory of the subprocess, and to avoid running multiple benchmark iterations when the file is missing, we should convert query_file to an absolute path and validate its existence upfront.

Suggested change
query = args.query
query_file = args.query_file
generate_rows = args.generate_rows
generate_cols = args.generate_cols
query = args.query
query_file = args.query_file
if query_file:
query_file = os.path.abspath(query_file)
if not os.path.isfile(query_file):
import sys
print(f"Error: Query file '{query_file}' does not exist.", file=sys.stderr)
sys.exit(1)
generate_rows = args.generate_rows
generate_cols = args.generate_cols

new_label=new_label,
diff_label=diff_label,
spec_name=f"Rows: {args.generate_rows}, Cols: {args.generate_cols}" if args.generate_rows > 0 else args.query,
spec_name=query if query else (f"File: {query_file}" if query_file else f"Rows: {generate_rows}, Cols: {generate_cols}"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since query_file is now resolved to an absolute path, using the full path in spec_name can make the generated markdown table columns excessively wide. It is cleaner to use only the filename via os.path.basename.

Suggested change
spec_name=query if query else (f"File: {query_file}" if query_file else f"Rows: {generate_rows}, Cols: {generate_cols}"),
spec_name=query if query else (f"File: {os.path.basename(query_file)}" if query_file else f"Rows: {generate_rows}, Cols: {generate_cols}"),

Comment on lines 104 to 107
if (query == null) {
System.err.println("Error: --query or --generate-rows is required when action is 'query'");
System.err.println("Error: --query, --query-file, or --generate-rows is required when action is 'query'");
System.exit(1);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the user provides an empty query string (e.g., --query "") or an empty query file, the client will proceed to execute it and fail with a less descriptive JDBC driver error. Adding a check for empty/blank queries improves usability.

Suggested change
if (query == null) {
System.err.println("Error: --query or --generate-rows is required when action is 'query'");
System.err.println("Error: --query, --query-file, or --generate-rows is required when action is 'query'");
System.exit(1);
}
if (query == null) {
System.err.println("Error: --query, --query-file, or --generate-rows is required when action is 'query'");
System.exit(1);
}
if (query.trim().isEmpty()) {
System.err.println("Error: Query cannot be empty");
System.exit(1);
}

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.

1 participant