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
3 changes: 3 additions & 0 deletions pkg-r/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# querychat (development version)


* Added support for Snowflake Semantic Views. When connected to Snowflake via DBI, querychat automatically discovers available Semantic Views and includes their definitions in the system prompt. This helps the LLM generate correct queries using the `SEMANTIC_VIEW()` table function with certified business metrics and dimensions. (#200)

* `QueryChat$new()` now supports deferred data source. Pass `data_source = NULL` at initialization time, then provide the actual data source via the `data_source` parameter of `$server()` or by setting the `$data_source` property. This enables use cases where the data source depends on session-specific authentication or per-user database connections. (#202)

* `DBISource` now uses database-agnostic SQL for column and type detection, replacing `LIMIT` syntax with `WHERE 1=0` and `dbFetch(n=1)`. This fixes compatibility with SQL Server and other databases that don't support `LIMIT`. (#112, #197)

# querychat 0.2.0

* The update tool now requires that the SQL query returns all columns from the original data source, ensuring that the dashboard can display the complete data frame after filtering or sorting. If the query does not return all columns, an informative error message will be provided. (#180)
Expand Down
11 changes: 7 additions & 4 deletions pkg-r/R/DBISource.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ DBISource <- R6::R6Class(
self$table_name <- table_name

# Store original column names for validation
# Use WHERE 1=0 instead of LIMIT 0 for SQL Server compatibility
private$colnames <- colnames(DBI::dbGetQuery(
conn,
sprintf(
"SELECT * FROM %s LIMIT 0",
"SELECT * FROM %s WHERE 1=0",
DBI::dbQuoteIdentifier(conn, table_name)
)
))
Expand Down Expand Up @@ -219,12 +220,14 @@ get_schema_impl <- function(
text_columns <- character(0)

# Get sample of data to determine types
# Use dbFetch(n=1) instead of LIMIT 1 for SQL Server compatibility
sample_query <- paste0(
"SELECT * FROM ",
DBI::dbQuoteIdentifier(conn, table_name),
" LIMIT 1"
DBI::dbQuoteIdentifier(conn, table_name)
)
sample_data <- DBI::dbGetQuery(conn, prep_query(sample_query))
rs <- DBI::dbSendQuery(conn, prep_query(sample_query))
sample_data <- DBI::dbFetch(rs, n = 1)
DBI::dbClearResult(rs)

for (col in columns) {
col_class <- class(sample_data[[col]])[1]
Expand Down
Loading