-
Notifications
You must be signed in to change notification settings - Fork 62
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: export queryFieldInfo and jsType #625
feat: export queryFieldInfo and jsType #625
Conversation
Thanks @kwonoh. This looks like a reasonable and straightforward modification. Can you share a bit more about why you'd like to have these methods exported? (It helps us to keep track of various use cases!) |
Hi @jheer,
|
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.
Overall looks good. If we're going to expose the queryFieldInfo
method, we should also add jsdoc comments and types before merging.
Addressing test failures |
@jheer I have added the jsdoc and type definitions. Now, it passes the tests, but please review the types closely. Some notes and questions:
|
@@ -27,7 +27,7 @@ export function coordinator(instance) { | |||
} | |||
|
|||
/** | |||
* @typedef {import('@uwdata/mosaic-sql').Query | string} QueryType | |||
* @typedef {import('@uwdata/mosaic-sql').Query | import('@uwdata/mosaic-sql').DescribeQuery | string} QueryType |
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.
DescribeQuery
was missing as a QueryType
causing an error
* table: string | import('@uwdata/mosaic-sql').TableRefNode, | ||
* column: (string | import('@uwdata/mosaic-sql').ColumnRefNode) & { aggregate?: boolean }, | ||
* stats?: Stat[] | Set<Stat> | ||
* }} FieldInfoRequest |
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.
Not sure FieldInfoRequest
is a good name for a type that represents the return type of MosaicClient.fields
and the type of fields
param of queryFieldInfo
* | ||
* @typedef {{ | ||
* table: FieldInfoRequest["table"], | ||
* column: string, |
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.
While FieldInfoRequest.column
is string | ColumnRefNode
, both getFieldInfo
and getTableInfo
return only string
type for column
field.
@@ -134,18 +134,20 @@ export class Coordinator { | |||
* or a SQL string. | |||
* @param {object} [options] An options object. | |||
* @param {'arrow' | 'json'} [options.type] The query result format type. | |||
* @param {boolean} [options.cache=true] If true, cache the query result. | |||
* @param {boolean} [options.cache=true] If true, cache the query result in the client (QueryManager). | |||
* @param {boolean} [options.persist=false] If true, persist cached query result in the server. |
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.
persist
option was missing in the type definition causing an error
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.
Can you say more about where the error was coming from? I believe persist
should be part of the aggregated ...options
, not broken out individually.
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.
Can you say more about where the error was coming from?
The type error was from { persist: true }
ingetFieldInfo
. Currently, there is no persist
field in the options
type info of Coordinator.query
here.
I believe persist should be part of the aggregated ...options, not broken out individually.
persist
type info is added as a member of options
object (options.persist
not persist
), not as a separate field. Do you want to add a new interface type definition for options
separately?
or did you mean there should be no default value assignment for persist
?
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 now see what you mean. Updated the code.
packages/core/src/Coordinator.js
Outdated
* @param {number} [options.priority] The query priority, defaults to | ||
* `Priority.Normal`. | ||
* @returns {QueryResult} A query result promise. | ||
*/ | ||
query(query, { | ||
type = 'arrow', | ||
cache = true, | ||
persist = false, |
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 default value of persist
differs depending on the server implementation
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.
persist = false,
has been removed as it needs to be part of ...options
.
But that means the default value of persist
should be the same across the servers
@@ -134,18 +134,20 @@ export class Coordinator { | |||
* or a SQL string. | |||
* @param {object} [options] An options object. | |||
* @param {'arrow' | 'json'} [options.type] The query result format type. | |||
* @param {boolean} [options.cache=true] If true, cache the query result. | |||
* @param {boolean} [options.cache=true] If true, cache the query result in the client (QueryManager). | |||
* @param {boolean} [options.persist=false] If true, persist cached query result in the server. |
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.
Can you say more about where the error was coming from? I believe persist
should be part of the aggregated ...options
, not broken out individually.
8f4d75f
to
1bbfb88
Compare
Thanks! |
export two utils functions
queryFieldInfo
andjsType