question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retrieve compiled SQL query

See original GitHub issue

Hello and thanks for this wonderful lib !

On my project, I use AWS S3 Select feature on CSVs stored in S3. It allows executing a SQL-like query directly on those CSVs:

import { S3Client, SelectObjectContentCommand } from '@aws-sdk/client-s3';

const s3Client = new s3Client()

const Response = await s3Client.send(
  new SelectObjectContentCommand({
    ... // some serialization options
    ExpressionType: 'SQL',
    Expression: `
      SELECT ...
      FROM S3Object
      WHERE ...
    `
  })
);

I would really like using kysely to build such queries but for the moment I cannot:

  • I haven’t found a way to simply retrieve the compiled SQL query string to provide it to the S3Client
  • The Kysely class constructor requires a dialect whereas I don’t really need one (other solution is to build an adapter for S3Select but that’s a whole lotta work)

Would it be possible to make dialect optional in the constructor (and throw an error if none is found when needed) and expose a compileQuery method on the db to retrieve the compiled query ?

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
koskimascommented, Dec 6, 2022

Normally you should never “hydrate” parameters to the SQL string. That’s a sure way to get your system pwned. For that reason, there’s no built in way to do it.

2reactions
igalklebanovcommented, Dec 6, 2022

Hey 👋

You can brew a dialect with existing built-in components and replace the driver with built-in DummyDriver.

This is documented in the browser example.

Now just use .compile() with any of the query builders to get CompiledQuery instances that contain sql and parameters fields.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I get a raw, compiled SQL query from a SQLAlchemy ...
I have a SQLAlchemy query object and want to get the text of the compiled SQL statement, with all its parameters bound (e.g....
Read more >
Get SQL Command Compile time - SQLServerCentral
Get SQL Command Compile time · 1. SET STATISTICS TIME ON · 2. SQL Profiler (or SQL Trace) · a) SQL Batch ·...
Read more >
How to find compiled parameter values for SQL Server cached ...
In this tip we look at how to use SSMS and T-SQL to find the parameter values that were used to create the...
Read more >
Inside SQL Server: Parse, Compile, and Optimize - ITPro Today
The relational engine parses the submitted statements, optimizes the SQL statements, compiles the code, and manages the query execution. During execution, ...
Read more >
Frequent query recompilations - a SQL query performance killer
A compilation is the process when a stored procedure's query execution plan is optimized, based on the current database and database objects ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found