-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Expose LogicalType(s) for columns in QueryResult, fix #24 #25
Open
ovr
wants to merge
6
commits into
duckdb:main
Choose a base branch
from
ovr:feat/query-result-expose-column-metadata
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+52
−13
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f0e40e7
feat: Expose LogicalType(s) for columns in QueryResult, fix #24
ovr 693e2a4
chore: type
ovr 6169c7b
chore: correct type
ovr dd42ca9
chore: review, same api as Statement.columns()
ovr 39f4c4f
chore: column can return null only for Statement
ovr 7a66f67
chore: assert
ovr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,14 @@ QueryResult.prototype.nextChunk; | |
*/ | ||
QueryResult.prototype.nextIpcBuffer; | ||
|
||
/** | ||
* Function to return logical types for columns | ||
* | ||
* @method | ||
* @return {ColumnInfo[]} - Array of column names and types | ||
*/ | ||
QueryResult.prototype.columns; | ||
|
||
/** | ||
* @name asyncIterator | ||
* @memberof module:duckdb~QueryResult | ||
|
@@ -218,12 +226,9 @@ Connection.prototype.each = function (sql) { | |
* @param {...*} params | ||
* @yields row chunks | ||
*/ | ||
Connection.prototype.stream = async function* (sql) { | ||
Connection.prototype.stream = async function (sql) { | ||
const statement = new Statement(this, sql); | ||
const queryResult = await statement.stream.apply(statement, arguments); | ||
for await (const result of queryResult) { | ||
yield result; | ||
} | ||
return statement.stream.apply(statement, arguments); | ||
} | ||
|
||
/** | ||
|
@@ -713,7 +718,7 @@ Statement.prototype.sql; | |
|
||
/** | ||
* @method | ||
* @return {ColumnInfo[]} - Array of column names and types | ||
* @return {ColumnInfo[] | null} - Array of column names and types | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
*/ | ||
Statement.prototype.columns; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description of change:
The old version used AsyncIterator (function was marked with
*
), which will lead to the wrong return type (notQueryResult
) + unexpected iteration over another iterator.Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What problem does this solve?
This will break the current API and require changes elsewhere that is doable but unsure if it makes sense here.
Could the GetColumns itself not be an async function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It started to return
QueryResult
which is declared in typings, when the old one returnAsyncGenerator
.It's not possible to call
getColumns
on top ofAsyncIterator
.Example to demo that
async *
returns AsyncGenerator.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the current version returns a class wrapping an AsyncGenerator.
Something like:
An instance of this class can behave like an async generator (so
var c = new MyClass; for await (var obj of c) ...
, but can also have methods of its own likec.someSyncMethod()
orawait c.someAsyncMethod()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The biggest problem that, old variant is an
AsyncGenerator
on top ofQueryResult
(local scoped), which implementsasyncIterator
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I see the problem as you are seeing it, could you go over it once again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it clear?