`describe_table` fails on SQL Server

Open Beginner friendly
#468 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
80/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
r, sql
Domain
databases

Research direction

Start from the describe_table code that builds the fallback sampling query with sprintf and n_fallback_rows, since LIMIT is the failing part. Reproduce the error against a SQL Server connection, or check the generated SQL in the error text. Done when the fallback uses a portable zero-row query (WHERE 1 = 0) that still returns typed columns, and the existing tests pass.

Written by the indexing model from the issue text.

Description

For a generic DBI connection, describe_table works out column types by sampling rows:

sprintf("SELECT * FROM %s LIMIT %d", DBI::dbQuoteIdentifier(con, id), n_fallback_rows)

T-SQL has no LIMIT, so this fails for every table on SQL Server:

✖ Incorrect syntax near '5'.
• <SQL> 'SELECT * FROM "shop"."dbo"."sales" LIMIT 5'

A zero-row query (SELECT * FROM x WHERE 1 = 0) is portable and still returns typed columns. Other backends without LIMIT, like Oracle, likely fail the same way.

Dominant language
Python
Stars
69
Forks
5
Avg merge
5d 13h
Merged PRs (30d)
30

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from posit-dev/commons

All issues in posit-dev/commons

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.