Skip to content

Commit 4f32d5e

Browse files
kravets-levkoJesse
and
Jesse
authored
Prepare release v1.5.0 (#179)
* Update library version Signed-off-by: Levko Kravets <[email protected]> * Update changelog Signed-off-by: Levko Kravets <[email protected]> * Minor code fixes Signed-off-by: Levko Kravets <[email protected]> * Update changelog Signed-off-by: Levko Kravets <[email protected]> * Apply suggestions from code review Signed-off-by: Levko Kravets <[email protected]> Co-authored-by: Jesse <[email protected]> * Fix example in changelog Signed-off-by: Levko Kravets <[email protected]> * Update changelog Signed-off-by: Levko Kravets <[email protected]> * Apply suggestions from code review Signed-off-by: Levko Kravets <[email protected]> Co-authored-by: Jesse <[email protected]> * Code style Signed-off-by: Levko Kravets <[email protected]> * Temporarily disable tests until we fix e2e env Signed-off-by: Levko Kravets <[email protected]> --------- Signed-off-by: Levko Kravets <[email protected]> Co-authored-by: Jesse <[email protected]>
1 parent 1bebee4 commit 4f32d5e

6 files changed

+100
-9
lines changed

CHANGELOG.md

+90
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,95 @@
11
# Release History
22

3+
## 1.5.0
4+
5+
### Highlights
6+
7+
- Added OAuth M2M support (databricks/databricks-sql-nodejs#168, databricks/databricks-sql-nodejs#177)
8+
- Added named query parameters support (databricks/databricks-sql-nodejs#162, databricks/databricks-sql-nodejs#175)
9+
- `runAsync` options is now deprecated (databricks/databricks-sql-nodejs#176)
10+
- Added staging ingestion support (databricks/databricks-sql-nodejs#164)
11+
12+
### Databricks OAuth support
13+
14+
Databricks OAuth support added in v1.4.0 is now extended with M2M flow. To use OAuth instead of PAT, pass
15+
a corresponding auth provider type and options to `DBSQLClient.connect`:
16+
17+
```ts
18+
// instantiate DBSQLClient as usual
19+
20+
client.connect({
21+
// provide other mandatory options as usual - e.g. host, path, etc.
22+
authType: 'databricks-oauth',
23+
oauthClientId: '...', // optional - overwrite default OAuth client ID
24+
azureTenantId: '...', // optional - provide custom Azure tenant ID
25+
persistence: ..., // optional - user-provided storage for OAuth tokens, should implement OAuthPersistence interface
26+
})
27+
```
28+
29+
U2M flow involves user interaction - the library will open a browser tab asking user to log in. To use this flow,
30+
no other options are required except for `authType`.
31+
32+
M2M flow does not require any user interaction, and therefore is a good option, say, for scripting. To use this
33+
flow, two extra options are required for `DBSQLClient.connect`: `oauthClientId` and `oauthClientSecret`.
34+
35+
Also see [Databricks docs](https://docs.databricks.com/en/dev-tools/auth.html#oauth-machine-to-machine-m2m-authentication)
36+
for more details about Databricks OAuth.
37+
38+
### Named query parameters
39+
40+
v1.5.0 adds a support for [query parameters](https://docs.databricks.com/en/sql/language-manual/sql-ref-parameter-marker.html).
41+
Currently only named parameters are supported.
42+
43+
Basic usage example:
44+
45+
```ts
46+
// obtain session object as usual
47+
48+
const operation = session.executeStatement('SELECT :p1 AS "str_param", :p2 AS "number_param"', {
49+
namedParameters: {
50+
p1: 'Hello, World',
51+
p2: 3.14,
52+
},
53+
});
54+
```
55+
56+
The library will infer parameter types from passed primitive objects. Supported data types include booleans, various
57+
numeric types (including native `BigInt` and `Int64` from `node-int64`), native `Date` type, and string.
58+
59+
It's also possible to explicitly specify the parameter type by passing `DBSQLParameter` instances instead of primitive
60+
values. It also allows one to use values that don't have a corresponding primitive representation:
61+
62+
```ts
63+
import { ..., DBSQLParameter, DBSQLParameterType } from '@databricks/sql';
64+
65+
// obtain session object as usual
66+
67+
const operation = session.executeStatement('SELECT :p1 AS "date_param", :p2 AS "interval_type"', {
68+
namedParameters: {
69+
p1: new DBSQLParameter({
70+
value: new Date('2023-09-06T03:14:27.843Z'),
71+
type: DBSQLParameterType.DATE, // by default, Date objects are inferred as TIMESTAMP, this allows to override the type
72+
}),
73+
p2: new DBSQLParameter({
74+
value: 5, // INTERVAL '5' DAY
75+
type: DBSQLParameterType.INTERVALDAY
76+
}),
77+
},
78+
});
79+
```
80+
81+
Of course, you can mix primitive values and `DBSQLParameter` instances.
82+
83+
### `runAsync` deprecation
84+
85+
Starting with this release, the library will execute all queries asynchronously, so we have deprecated
86+
the `runAsync` option. It will be completely removed in v2. So you should not use it going forward and remove all
87+
the usages from your code before version 2 is released. From user's perspective the library behaviour won't change.
88+
89+
### Data ingestion support
90+
91+
This feature allows you to upload, retrieve, and remove unity catalog volume files using SQL `PUT`, `GET` and `REMOVE` commands.
92+
393
## 1.4.0
494

595
- Added Cloud Fetch support (databricks/databricks-sql-nodejs#158)

lib/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import TCLIService from '../thrift/TCLIService';
33
import TCLIService_types from '../thrift/TCLIService_types';
44
import DBSQLClient from './DBSQLClient';
55
import DBSQLSession from './DBSQLSession';
6-
import { DBSQLParameter } from './DBSQLParameter';
6+
import { DBSQLParameter, DBSQLParameterType } from './DBSQLParameter';
77
import DBSQLLogger from './DBSQLLogger';
88
import PlainHttpAuthentication from './connection/auth/PlainHttpAuthentication';
99
import HttpConnection from './connection/connections/HttpConnection';
@@ -32,4 +32,4 @@ export const utils = {
3232
formatProgress,
3333
};
3434

35-
export { DBSQLClient, DBSQLSession, DBSQLParameter, DBSQLLogger, LogLevel };
35+
export { DBSQLClient, DBSQLSession, DBSQLParameter, DBSQLParameterType, DBSQLLogger, LogLevel };

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@databricks/sql",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "Driver for connection to Databricks SQL via Thrift API.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

tests/e2e/query_parameters.test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { expect } = require('chai');
22
const Int64 = require('node-int64');
33
const config = require('./utils/config');
4-
const { DBSQLClient, DBSQLParameter } = require('../..');
4+
const { DBSQLClient, DBSQLParameter, DBSQLParameterType } = require('../..');
55

66
const openSession = async () => {
77
const client = new DBSQLClient();
@@ -18,7 +18,8 @@ const openSession = async () => {
1818
});
1919
};
2020

21-
describe('Query parameters', () => {
21+
// TODO: Temporarily disable those tests until we figure out issues with E2E test env
22+
describe.skip('Query parameters', () => {
2223
it('should use named parameters', async () => {
2324
const session = await openSession();
2425
const operation = await session.executeStatement(
@@ -40,7 +41,7 @@ describe('Query parameters', () => {
4041
p_double: new DBSQLParameter({ value: 3.14 }),
4142
p_bigint_1: new DBSQLParameter({ value: BigInt(1234) }),
4243
p_bigint_2: new DBSQLParameter({ value: new Int64(1234) }),
43-
p_date: new DBSQLParameter({ value: new Date('2023-09-06T03:14:27.843Z'), type: 'DATE' }),
44+
p_date: new DBSQLParameter({ value: new Date('2023-09-06T03:14:27.843Z'), type: DBSQLParameterType.DATE }),
4445
p_timestamp: new DBSQLParameter({ value: new Date('2023-09-06T03:14:27.843Z') }),
4546
p_str: new DBSQLParameter({ value: 'Hello' }),
4647
},

tests/e2e/staging_ingestion.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const config = require('./utils/config');
33
const { DBSQLClient } = require('../..');
44
const fs = require('fs');
55

6-
// TODO Temporarily disable those tests until we figure out issues with E2E test env
6+
// TODO: Temporarily disable those tests until we figure out issues with E2E test env
77
describe.skip('Staging Test', () => {
88
it('put staging data and receive it', async () => {
99
const client = new DBSQLClient();

0 commit comments

Comments
 (0)