posit-dev / posit-dev/querychat

R: ODBC encoding error with Snowflake DBI connections - `wstring_convert::to_bytes`

Open
#213 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
212
Forks
29
Avg merge
22h 24m
Merged PRs (30d)
27

Description

Description

When attempting to use a Snowflake DBI connection directly with QueryChat$new(), I encounter an ODBC character encoding error.

Environment:

  • querychat: v0.2.0.9000 (dev version via pak::pak("posit-dev/querychat/pkg-r"))
  • R version: 4.5
  • Environment: Posit Team Snowflake Native App, Positron within Workbench
  • Snowflake ODBC driver

Reproducible Example:

  library(querychat)
  library(DBI)
  library(odbc)

  # Initialize Snowflake connection
  con <- DBI::dbConnect(
    odbc::snowflake(),
    account = Sys.getenv("SNOWFLAKE_ACCOUNT"),
    warehouse = "DEFAULT_WH",
    database = "SNOWFLAKE_PUBLIC_DATA_FREE",
    schema = "PUBLIC_DATA_FREE"
  )

  # Verify connection works
  DBI::dbListTables(con)  # This works fine

  # Attempt to create QueryChat with the connection
  qc <- QueryChat$new(con, "HOME_MORTGAGE_DISCLOSURE_ATTRIBUTES")

Error:
Error: wstring_convert::to_bytes

Additional details:

Warning: Error in : wstring_convert::to_bytes
  56: <Anonymous>
  55: stop
  54: connection_sql_tables
  53: .local
  52: odbcConnectionTables
  50: DBI::dbExistsTable
  48: initialize
  47: DBISource$new
  46: normalize_data_source
  45: initialize
  44: QueryChat$new
Questions:
  • Is there a known issue with Snowflake ODBC drivers and QueryChat (R)?
  • Are there any configuration options or workarounds to enable direct Snowflake connection support?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Snowflake connection failure with QueryChat$new and trace the reported path through normalize_data_source, DBISource$new, connection_sql_tables, odbcConnectionTables, and DBI::dbExistsTable. Compare the working dbListTables call with the failing initialization and determine whether direct Snowflake connections need a supported configuration or compatibility change; done means the behavior or workaround is documented and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.