duckdb 0.9.1-dev97.0 → 0.9.2-dev10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/.github/workflows/HighPriorityIssues.yml +36 -0
  2. package/.github/workflows/NodeJS.yml +250 -0
  3. package/LICENSE +7 -0
  4. package/Makefile +3 -9
  5. package/README.md +2 -2
  6. package/binding.gyp +8 -8
  7. package/lib/duckdb.d.ts +18 -0
  8. package/lib/duckdb.js +12 -0
  9. package/package.json +4 -4
  10. package/scripts/install_node.sh +21 -0
  11. package/scripts/node_build.sh +40 -0
  12. package/scripts/node_build_win.sh +21 -0
  13. package/scripts/node_version.sh +33 -0
  14. package/src/database.cpp +30 -1
  15. package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
  16. package/src/duckdb/extension/icu/icu-strptime.cpp +0 -2
  17. package/src/duckdb/extension/icu/icu_extension.cpp +0 -1
  18. package/src/duckdb/extension/json/json_functions/json_create.cpp +27 -14
  19. package/src/duckdb/extension/json/json_functions/json_transform.cpp +26 -14
  20. package/src/duckdb/extension/json/json_functions.cpp +1 -10
  21. package/src/duckdb/extension/parquet/column_reader.cpp +26 -1
  22. package/src/duckdb/extension/parquet/column_writer.cpp +10 -1
  23. package/src/duckdb/extension/parquet/include/column_reader.hpp +2 -0
  24. package/src/duckdb/extension/parquet/include/parquet_bss_decoder.hpp +49 -0
  25. package/src/duckdb/extension/parquet/parquet_extension.cpp +3 -4
  26. package/src/duckdb/extension/parquet/parquet_timestamp.cpp +3 -4
  27. package/src/duckdb/src/common/arrow/appender/list_data.cpp +2 -2
  28. package/src/duckdb/src/common/arrow/appender/map_data.cpp +15 -10
  29. package/src/duckdb/src/common/arrow/appender/struct_data.cpp +2 -2
  30. package/src/duckdb/src/common/arrow/appender/union_data.cpp +2 -2
  31. package/src/duckdb/src/common/arrow/arrow_appender.cpp +26 -7
  32. package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +3 -3
  33. package/src/duckdb/src/common/exception.cpp +60 -84
  34. package/src/duckdb/src/common/preserved_error.cpp +20 -0
  35. package/src/duckdb/src/common/types/data_chunk.cpp +1 -1
  36. package/src/duckdb/src/execution/expression_executor/execute_reference.cpp +1 -1
  37. package/src/duckdb/src/execution/expression_executor_state.cpp +8 -2
  38. package/src/duckdb/src/execution/operator/csv_scanner/buffered_csv_reader.cpp +1 -1
  39. package/src/duckdb/src/execution/operator/csv_scanner/csv_state_machine_cache.cpp +2 -0
  40. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp +5 -5
  41. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +4 -4
  42. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_replacement.cpp +2 -2
  43. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +1 -4
  44. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +2 -4
  45. package/src/duckdb/src/function/function_binder.cpp +1 -1
  46. package/src/duckdb/src/function/table/arrow_conversion.cpp +2 -1
  47. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  48. package/src/duckdb/src/include/duckdb/common/arrow/appender/append_data.hpp +4 -0
  49. package/src/duckdb/src/include/duckdb/common/arrow/appender/enum_data.hpp +3 -1
  50. package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +2 -1
  51. package/src/duckdb/src/include/duckdb/common/arrow/arrow_wrapper.hpp +3 -0
  52. package/src/duckdb/src/include/duckdb/common/exception.hpp +1 -0
  53. package/src/duckdb/src/include/duckdb/common/preserved_error.hpp +1 -3
  54. package/src/duckdb/src/include/duckdb/execution/expression_executor_state.hpp +1 -1
  55. package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/base_csv_reader.hpp +0 -4
  56. package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_sniffer.hpp +10 -10
  57. package/src/duckdb/src/include/duckdb/function/replacement_scan.hpp +20 -0
  58. package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
  59. package/src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp +2 -0
  60. package/src/duckdb/src/include/duckdb/planner/binder.hpp +1 -0
  61. package/src/duckdb/src/include/duckdb/planner/bound_parameter_map.hpp +3 -0
  62. package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +2 -2
  63. package/src/duckdb/src/main/capi/arrow-c.cpp +7 -4
  64. package/src/duckdb/src/main/config.cpp +14 -0
  65. package/src/duckdb/src/main/extension/extension_install.cpp +14 -12
  66. package/src/duckdb/src/optimizer/filter_pushdown.cpp +1 -0
  67. package/src/duckdb/src/optimizer/pushdown/pushdown_distinct.cpp +19 -0
  68. package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +4 -2
  69. package/src/duckdb/src/parser/transform/statement/transform_create_sequence.cpp +10 -5
  70. package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +5 -7
  71. package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +4 -2
  72. package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +17 -14
  73. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +5 -12
  74. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +15 -1
  75. package/src/duckdb/src/planner/bound_parameter_map.cpp +16 -5
  76. package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +2 -5
  77. package/src/duckdb/src/planner/planner.cpp +1 -1
  78. package/src/duckdb/src/transaction/duck_transaction_manager.cpp +13 -9
  79. package/src/duckdb/third_party/parquet/parquet_types.h +2 -1
  80. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +5 -5
  81. package/src/duckdb/ub_src_optimizer_pushdown.cpp +2 -0
  82. package/src/duckdb_node.cpp +29 -8
  83. package/src/duckdb_node.hpp +2 -0
  84. package/src/statement.cpp +13 -4
  85. package/test/arrow.test.ts +3 -1
  86. package/test/parquet.test.ts +1 -1
  87. package/test/test_all_types.test.ts +13 -12
  88. package/test/tokenize.test.ts +74 -0
  89. package/test/userdata1.parquet +0 -0
  90. package/{configure → vendor} +1 -1
  91. package/{configure.py → vendor.py} +12 -1
  92. package/duckdb_extension_config.cmake +0 -10
@@ -0,0 +1,36 @@
1
+ name: Create Internal issue when the "High Priority" label is applied
2
+ on:
3
+ issues:
4
+ types:
5
+ - labeled
6
+
7
+ env:
8
+ GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }}
9
+ # an event triggering this workflow is either an issue or a pull request,
10
+ # hence only one of the numbers will be filled in the TITLE_PREFIX
11
+ TITLE_PREFIX: "[duckdb-node/#${{ github.event.issue.number }}]"
12
+ PUBLIC_ISSUE_TITLE: ${{ github.event.issue.title }}
13
+
14
+ jobs:
15
+ create_or_label_issue:
16
+ if: github.event.label.name == 'High Priority'
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - name: Get mirror issue number
20
+ run: |
21
+ gh issue list --repo duckdblabs/duckdb-internal --search "${TITLE_PREFIX}" --json title,number --jq ".[] | select(.title | startswith(\"$TITLE_PREFIX\")).number" > mirror_issue_number.txt
22
+ echo "MIRROR_ISSUE_NUMBER=$(cat mirror_issue_number.txt)" >> $GITHUB_ENV
23
+
24
+ - name: Print whether mirror issue exists
25
+ run: |
26
+ if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then
27
+ echo "Mirror issue with title prefix '$TITLE_PREFIX' does not exist yet"
28
+ else
29
+ echo "Mirror issue with title prefix '$TITLE_PREFIX' exists with number $MIRROR_ISSUE_NUMBER"
30
+ fi
31
+
32
+ - name: Create or label issue
33
+ run: |
34
+ if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then
35
+ gh issue create --repo duckdblabs/duckdb-internal --label "Node.js" --label "High Priority" --title "$TITLE_PREFIX - $PUBLIC_ISSUE_TITLE" --body "See https://github.com/duckdb/duckdb/issues/${{ github.event.issue.number }}"
36
+ else
@@ -0,0 +1,250 @@
1
+ name: NodeJS
2
+ on:
3
+ push:
4
+ pull_request:
5
+
6
+ concurrency:
7
+ group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }}
8
+ cancel-in-progress: false
9
+
10
+ env:
11
+ GH_TOKEN: ${{ secrets.GH_TOKEN }}
12
+ AWS_ACCESS_KEY_ID: ${{ secrets.NODE_PRE_GYP_ID }}
13
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.NODE_PRE_GYP_SECRETACCESSKEY }}
14
+
15
+ jobs:
16
+ set-up-npm:
17
+ name: Set up NPM
18
+ runs-on: ubuntu-20.04
19
+ env:
20
+ DUCKDB_NODE_BUILD_CACHE: 0
21
+ steps:
22
+ - uses: actions/checkout@v3
23
+ with:
24
+ fetch-depth: 0
25
+
26
+ - name: Setup NPM
27
+ shell: bash
28
+ run: ./scripts/node_version.sh upload
29
+ env:
30
+ DUCKDB_NODE_BUILD_CACHE: 0 # create a standalone package
31
+ NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
32
+
33
+ linux-nodejs:
34
+ name: node.js Linux
35
+ runs-on: ubuntu-20.04
36
+ needs: set-up-npm
37
+ env:
38
+ TARGET_ARCH: ${{ matrix.target_arch }}
39
+ DUCKDB_NODE_BUILD_CACHE: 0
40
+ strategy:
41
+ matrix:
42
+ # node.js current support policy to be found at https://github.com/duckdb/duckdb-node/tree/main/#Supported-Node-versions
43
+ node: [ '12', '14', '16', '17', '18', '19', '20' ]
44
+ target_arch: [ x64, arm64 ]
45
+ isRelease:
46
+ - ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
47
+ exclude:
48
+ - isRelease: false
49
+ node: 12
50
+ target_arch: x64
51
+ - isRelease: false
52
+ node: 14
53
+ target_arch: x64
54
+ - isRelease: false
55
+ node: 16
56
+ target_arch: x64
57
+ - isRelease: false
58
+ node: 17
59
+ target_arch: x64
60
+ - isRelease: false
61
+ node: 18
62
+ target_arch: x64
63
+ - isRelease: false
64
+ node: 19
65
+ target_arch: x64
66
+ - isRelease: false
67
+ node: 12
68
+ target_arch: arm64
69
+ - isRelease: false
70
+ node: 14
71
+ target_arch: arm64
72
+ - isRelease: false
73
+ node: 16
74
+ target_arch: arm64
75
+ - isRelease: false
76
+ node: 17
77
+ target_arch: arm64
78
+ - isRelease: false
79
+ node: 18
80
+ target_arch: arm64
81
+ - isRelease: false
82
+ node: 19
83
+ target_arch: arm64
84
+ - isRelease: false
85
+ node: 20
86
+ target_arch: arm64
87
+
88
+ steps:
89
+ - uses: actions/checkout@v3
90
+ with:
91
+ fetch-depth: 0
92
+
93
+ - name: Update apt
94
+ shell: bash
95
+ run: |
96
+ sudo apt-get update -y
97
+
98
+ - name: Install requirements
99
+ shell: bash
100
+ run: |
101
+ sudo apt-get install -y git ninja-build make gcc-multilib g++-multilib wget libssl-dev
102
+
103
+ - name: Setup Ccache
104
+ uses: hendrikmuhs/ccache-action@main
105
+ with:
106
+ key: ${{ github.job }}
107
+ save: ${{ ( github.ref == 'refs/heads/main' || github.repository != 'duckdb/duckdb-node' ) && ( matrix.node == '19' ) }}
108
+
109
+ - name: Setup
110
+ shell: bash
111
+ run: ./scripts/node_version.sh
112
+ env:
113
+ DUCKDB_NODE_BUILD_CACHE: 0 # create a standalone package
114
+ NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
115
+
116
+ - name: Validate Docs
117
+ run: npx jsdoc-to-markdown --files lib/*.js >> $GITHUB_STEP_SUMMARY
118
+ env:
119
+ npm_config_yes: true
120
+
121
+ - name: Node ${{ matrix.node }}
122
+ shell: bash
123
+ run: ./scripts/node_build.sh ${{ matrix.node }}
124
+
125
+ osx-nodejs:
126
+ if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.repository != 'duckdb/duckdb-node'
127
+ name: node.js OSX
128
+ runs-on: macos-latest
129
+ needs: linux-nodejs
130
+ strategy:
131
+ matrix:
132
+ target_arch: [ x64, arm64 ]
133
+ node: [ '12', '14', '16', '17', '18', '19', '20' ]
134
+ isRelease:
135
+ - ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
136
+ exclude:
137
+ - isRelease: false
138
+ node: 12
139
+ - isRelease: false
140
+ node: 14
141
+ - isRelease: false
142
+ node: 16
143
+ - isRelease: false
144
+ node: 17
145
+ - isRelease: false
146
+ node: 18
147
+ - target_arch: arm64
148
+ node: 12
149
+ - target_arch: arm64
150
+ node: 14
151
+ # these older versions of NodeJS don't have M1 support
152
+
153
+ env:
154
+ TARGET_ARCH: ${{ matrix.target_arch }}
155
+ DUCKDB_NODE_BUILD_CACHE: 0
156
+ steps:
157
+ - uses: actions/checkout@v3
158
+ with:
159
+ fetch-depth: 0
160
+
161
+ - name: Setup Ccache
162
+ uses: hendrikmuhs/ccache-action@main
163
+ with:
164
+ key: ${{ github.job }}-${{ matrix.target_arch }}
165
+ save: ${{ ( github.ref == 'refs/heads/main' || github.repository != 'duckdb/duckdb-node' ) && ( matrix.node == '19' ) }}
166
+
167
+ - name: Downgrade curl # fixes a bug with the brew curl that lead to failed downloads
168
+ shell: bash
169
+ run: |
170
+ brew uninstall --ignore-dependencies curl
171
+ which curl
172
+
173
+ - name: Setup
174
+ shell: bash
175
+ run: ./scripts/node_version.sh
176
+ env:
177
+ NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
178
+
179
+ - name: Node ${{ matrix.node }}
180
+ shell: bash
181
+ run: ./scripts/node_build.sh ${{ matrix.node }}
182
+
183
+ win-nodejs:
184
+ name: node.js Windows
185
+ runs-on: windows-latest
186
+ needs: linux-nodejs
187
+ env:
188
+ npm_config_msvs_version: 2019
189
+
190
+ strategy:
191
+ matrix:
192
+ node: [ '12', '14', '16', '17', '18', '19', '20' ]
193
+ isRelease:
194
+ - ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
195
+ exclude:
196
+ - isRelease: false
197
+ node: 12
198
+ - isRelease: false
199
+ node: 14
200
+ - isRelease: false
201
+ node: 16
202
+ - isRelease: false
203
+ node: 17
204
+ - isRelease: false
205
+ node: 18
206
+ - isRelease: false
207
+ node: 19
208
+
209
+ steps:
210
+ - uses: actions/setup-python@v4
211
+ with:
212
+ python-version: '3.8'
213
+
214
+ - uses: actions/checkout@v3
215
+ with:
216
+ fetch-depth: 0
217
+
218
+ - name: Setup Node
219
+ uses: actions/setup-node@v3
220
+ with:
221
+ node-version: ${{ matrix.node }}
222
+
223
+ - name: Versions
224
+ shell: bash
225
+ run: |
226
+ systeminfo
227
+ node -v
228
+ npm -v
229
+
230
+ - name: Windows Build Tools
231
+ shell: bash
232
+ run: |
233
+ choco install visualstudio2019-workload-vctools -y
234
+
235
+ - name: Node Version
236
+ shell: bash
237
+ run: ./scripts/node_version.sh
238
+ env:
239
+ NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
240
+
241
+ - name: Setup Ccache
242
+ uses: hendrikmuhs/ccache-action@main
243
+ with:
244
+ key: ${{ github.job }}-${{ matrix.node }}
245
+ save: ${{ github.ref == 'refs/heads/main' || github.repository != 'duckdb/duckdb-node' }}
246
+ variant: sccache
247
+
248
+ - name: Node
249
+ shell: bash
250
+ run: ./scripts/node_build_win.sh
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2018-2023 Stichting DuckDB Foundation
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/Makefile CHANGED
@@ -1,15 +1,12 @@
1
1
  all: build
2
2
 
3
- src/duckdb/src/include/duckdb.hpp:
4
- ./configure
5
-
6
3
  ./node_modules:
7
- npm install --build-from-source
4
+ npm install --ignore-scripts
8
5
 
9
- build: ./node_modules src/duckdb/src/include/duckdb.hpp
6
+ build: ./node_modules
10
7
  ./node_modules/.bin/node-pre-gyp build -j max --loglevel=silent
11
8
 
12
- debug: ./node_modules src/duckdb/src/include/duckdb.hpp
9
+ debug: ./node_modules
13
10
  ./node_modules/.bin/node-pre-gyp build -j max --debug --verbose
14
11
 
15
12
  clean:
@@ -17,11 +14,8 @@ clean:
17
14
  rm -rf lib/binding/
18
15
  rm -f test/support/big.db-journal
19
16
  rm -rf ./node_modules/
20
- rm -rf src/duckdb/
21
- rm -f binding.gyp
22
17
 
23
18
  complete_build:
24
- ./configure
25
19
  npm install
26
20
 
27
21
  test:
package/README.md CHANGED
@@ -111,11 +111,11 @@ As per July 2023, Node 15 has been removed from the supported versions.
111
111
 
112
112
  ### First install:
113
113
 
114
- To install all the dev dependencies of the project, navigate over to `tools/nodejs` and run `npm install` (this uses package.json)
114
+ To install all the dev dependencies of the project, run `npm install` (this uses package.json)
115
115
  You might want to add the `--ignore-scripts` option if you don't care about building the package for now and just want to install the dependencies.
116
116
 
117
117
  ### Tests:
118
- Tests are located in `tools/nodejs/test` and can be run with `npm test`
118
+ Tests are located in `test` and can be run with `npm test`
119
119
  To run a single test, you can use `npm test -- --grep "name of test as given in describe"`
120
120
 
121
121
  ### Additional notes:
package/binding.gyp CHANGED
@@ -249,18 +249,18 @@
249
249
  "src/duckdb/third_party/zstd/compress/zstd_lazy.cpp",
250
250
  "src/duckdb/third_party/zstd/compress/zstd_ldm.cpp",
251
251
  "src/duckdb/third_party/zstd/compress/zstd_opt.cpp",
252
- "src/duckdb/extension/icu/./icu-timezone.cpp",
253
- "src/duckdb/extension/icu/./icu-datepart.cpp",
254
- "src/duckdb/extension/icu/./icu-timebucket.cpp",
255
- "src/duckdb/extension/icu/./icu-datesub.cpp",
256
- "src/duckdb/extension/icu/./icu-list-range.cpp",
252
+ "src/duckdb/extension/icu/./icu-table-range.cpp",
257
253
  "src/duckdb/extension/icu/./icu-makedate.cpp",
258
- "src/duckdb/extension/icu/./icu-datefunc.cpp",
259
- "src/duckdb/extension/icu/./icu-datetrunc.cpp",
254
+ "src/duckdb/extension/icu/./icu-list-range.cpp",
255
+ "src/duckdb/extension/icu/./icu-timebucket.cpp",
256
+ "src/duckdb/extension/icu/./icu-timezone.cpp",
260
257
  "src/duckdb/extension/icu/./icu-dateadd.cpp",
261
- "src/duckdb/extension/icu/./icu-table-range.cpp",
258
+ "src/duckdb/extension/icu/./icu-datetrunc.cpp",
259
+ "src/duckdb/extension/icu/./icu-datesub.cpp",
262
260
  "src/duckdb/extension/icu/./icu_extension.cpp",
263
261
  "src/duckdb/extension/icu/./icu-strptime.cpp",
262
+ "src/duckdb/extension/icu/./icu-datefunc.cpp",
263
+ "src/duckdb/extension/icu/./icu-datepart.cpp",
264
264
  "src/duckdb/ub_extension_icu_third_party_icu_common.cpp",
265
265
  "src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp",
266
266
  "src/duckdb/extension/icu/third_party/icu/stubdata/stubdata.cpp",
package/lib/duckdb.d.ts CHANGED
@@ -78,6 +78,8 @@ export type ArrowArray = Uint8Array[];
78
78
  export class Connection {
79
79
  constructor(db: Database, callback?: Callback<any>);
80
80
 
81
+ close(callback?: Callback<void>): void;
82
+
81
83
  all(sql: string, ...args: [...any, Callback<TableData>] | []): void;
82
84
  arrowIPCAll(sql: string, ...args: [...any, Callback<ArrowArray>] | []): void;
83
85
  each(sql: string, ...args: [...any, Callback<RowData>] | []): void;
@@ -127,6 +129,20 @@ export type ReplacementScanCallback = (
127
129
  table: string
128
130
  ) => ReplacementScanResult | null;
129
131
 
132
+ export enum TokenType {
133
+ IDENTIFIER = 0,
134
+ NUMERIC_CONSTANT = 1,
135
+ STRING_CONSTANT = 2,
136
+ OPERATOR = 3,
137
+ KEYWORD = 4,
138
+ COMMENT = 5,
139
+ }
140
+
141
+ export interface ScriptTokens {
142
+ offsets: number[];
143
+ types: TokenType[];
144
+ }
145
+
130
146
  export class Database {
131
147
  constructor(path: string, accessMode?: number | Record<string,string>, callback?: Callback<any>);
132
148
  constructor(path: string, callback?: Callback<any>);
@@ -169,6 +185,8 @@ export class Database {
169
185
  registerReplacementScan(
170
186
  replacementScan: ReplacementScanCallback
171
187
  ): Promise<void>;
188
+
189
+ tokenize(text: string): ScriptTokens;
172
190
  }
173
191
 
174
192
  export type GenericTypeInfo = {
package/lib/duckdb.js CHANGED
@@ -64,6 +64,10 @@ var Statement = duckdb.Statement;
64
64
  * @class
65
65
  */
66
66
  var QueryResult = duckdb.QueryResult;
67
+ /**
68
+ * Types of tokens return by `tokenize`.
69
+ */
70
+ var TokenType = duckdb.TokenType;
67
71
 
68
72
  /**
69
73
  * @method
@@ -631,6 +635,14 @@ Database.prototype.unregister_udf = function () {
631
635
 
632
636
  Database.prototype.registerReplacementScan;
633
637
 
638
+ /**
639
+ * Return positions and types of tokens in given text
640
+ * @method
641
+ * @arg text
642
+ * @return {ScriptTokens}
643
+ */
644
+ Database.prototype.tokenize;
645
+
634
646
  /**
635
647
  * Not implemented
636
648
  */
package/package.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.9.1-dev97.0",
5
+ "version": "0.9.2-dev10.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
9
9
  "@mapbox/node-pre-gyp": "^1.0.0",
10
- "node-addon-api": "*",
10
+ "node-addon-api": "^7.0.0",
11
11
  "node-gyp": "^9.3.0"
12
12
  },
13
13
  "binary": {
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "repository": {
47
47
  "type": "git",
48
- "url": "git+https://github.com/duckdb/duckdb.git"
48
+ "url": "git+https://github.com/duckdb/duckdb-node.git"
49
49
  },
50
50
  "ts-node": {
51
51
  "require": [
@@ -60,7 +60,7 @@
60
60
  "author": "Hannes Mühleisen",
61
61
  "license": "MIT",
62
62
  "bugs": {
63
- "url": "https://github.com/duckdb/duckdb/issues"
63
+ "url": "https://github.com/duckdb/duckdb-node/issues"
64
64
  },
65
65
  "homepage": "https://www.duckdb.org"
66
66
  }
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env bash
2
+
3
+ if [[ ${1:-false} == 'false' ]]; then
4
+ echo "Error: pass node version as first argument"
5
+ exit 1
6
+ fi
7
+
8
+ NODE_VERSION=$1
9
+
10
+ # if an existing nvm is already installed we need to unload it
11
+ nvm unload || true
12
+
13
+ # here we set up the node version on the fly based on the matrix value.
14
+ # This is done manually so that the build works the same on OS X
15
+ rm -rf ./__nvm/ && git clone --depth 1 https://github.com/creationix/nvm.git ./__nvm
16
+ source ./__nvm/nvm.sh
17
+ nvm install ${NODE_VERSION}
18
+ nvm use --delete-prefix ${NODE_VERSION}
19
+ node --version
20
+ npm --version
21
+ which node
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -ex
4
+
5
+ TARGET_ARCH=${TARGET_ARCH:=x64}
6
+ echo targeting arch: $TARGET_ARCH
7
+
8
+ set +x
9
+ source scripts/install_node.sh $1
10
+ set -x
11
+ make clean
12
+
13
+ if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ] && [[ "$TARGET_ARCH" == "arm64" ]] ; then
14
+ sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu --yes
15
+ export CC=aarch64-linux-gnu-gcc
16
+ export CXX=aarch64-linux-gnu-g++
17
+ fi
18
+
19
+ npm install --build-from-source --target_arch="$TARGET_ARCH"
20
+
21
+ ./node_modules/.bin/node-pre-gyp reveal --target_arch="$TARGET_ARCH"
22
+
23
+ if [[ "$TARGET_ARCH" != "arm64" ]] ; then
24
+ if [[ ! "$GITHUB_REF" =~ ^(refs/tags/v.+)$ ]] ; then
25
+ npm test
26
+ fi
27
+ else
28
+ ARCH=$(file lib/binding/duckdb.node | tr '[:upper:]' '[:lower:]')
29
+ if [[ "$ARCH" != *"arm"* ]] ; then
30
+ echo "no arch $ARCH"
31
+ exit 1
32
+ fi
33
+ fi
34
+
35
+ export PATH=$(npm bin):$PATH
36
+ ./node_modules/.bin/node-pre-gyp package testpackage testbinary --target_arch="$TARGET_ARCH"
37
+ if [[ "$GITHUB_REF" =~ ^(refs/heads/main|refs/tags/v.+)$ ]] ; then
38
+ ./node_modules/.bin/node-pre-gyp publish --target_arch=$TARGET_ARCH
39
+ ./node_modules/.bin/node-pre-gyp info --target_arch=$TARGET_ARCH
40
+ fi
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ node --version
6
+ npm --version
7
+ which node
8
+
9
+ make clean
10
+
11
+ npm install --build-from-source
12
+ # no tests on releases
13
+ if [[ ! "$GITHUB_REF" =~ ^(refs/tags/v.+)$ ]] ; then
14
+ npm test
15
+ fi
16
+ npx node-pre-gyp package testpackage testbinary
17
+
18
+ if [[ "$GITHUB_REF" =~ ^(refs/heads/main|refs/tags/v.+)$ ]] ; then
19
+ npx node-pre-gyp publish
20
+ npx node-pre-gyp info
21
+ fi
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -ex
4
+
5
+ git config --global user.email "quack@duckdb.org"
6
+ git config --global user.name "DuckDB Admin"
7
+
8
+
9
+ export TAG=''
10
+ # for main do prereleases
11
+ if [[ "$GITHUB_REF" =~ ^refs/tags/v.+$ ]] ; then
12
+ # proper release
13
+ npm version --no-git-tag-version `echo $GITHUB_REF | sed 's|refs/tags/v||'`
14
+ else
15
+ git describe --tags --long || exit
16
+
17
+ export VER=`git describe --tags --abbrev=0 | tr -d "v"`
18
+ export DIST=`git describe --tags --long | cut -f2 -d-`
19
+
20
+ # set version to lastver
21
+ npm version --no-git-tag-version $VER
22
+ npm version --no-git-tag-version prerelease --preid="dev"$DIST
23
+ export TAG='--tag next'
24
+ fi
25
+
26
+ npm pack --dry-run
27
+
28
+ # upload to npm, maybe
29
+ if [[ "$GITHUB_REF" =~ ^(refs/heads/main|refs/tags/v.+)$ && "$1" = "upload" ]] ; then
30
+ npm version
31
+ npm config set //registry.npmjs.org/:_authToken $NODE_AUTH_TOKEN
32
+ npm publish --access public $TAG
33
+ fi
package/src/database.cpp CHANGED
@@ -1,5 +1,6 @@
1
1
  #include "duckdb/parser/expression/constant_expression.hpp"
2
2
  #include "duckdb/parser/expression/function_expression.hpp"
3
+ #include "duckdb/parser/parser.hpp"
3
4
  #include "duckdb/parser/tableref/table_function_ref.hpp"
4
5
  #include "duckdb/storage/buffer_manager.hpp"
5
6
  #include "duckdb_node.hpp"
@@ -18,7 +19,8 @@ Napi::FunctionReference Database::Init(Napi::Env env, Napi::Object exports) {
18
19
  {InstanceMethod("close_internal", &Database::Close), InstanceMethod("wait", &Database::Wait),
19
20
  InstanceMethod("serialize", &Database::Serialize), InstanceMethod("parallelize", &Database::Parallelize),
20
21
  InstanceMethod("connect", &Database::Connect), InstanceMethod("interrupt", &Database::Interrupt),
21
- InstanceMethod("registerReplacementScan", &Database::RegisterReplacementScan)});
22
+ InstanceMethod("registerReplacementScan", &Database::RegisterReplacementScan),
23
+ InstanceMethod("tokenize", &Database::Tokenize)});
22
24
 
23
25
  exports.Set("Database", t);
24
26
 
@@ -364,4 +366,31 @@ Napi::Value Database::RegisterReplacementScan(const Napi::CallbackInfo &info) {
364
366
  return deferred.Promise();
365
367
  }
366
368
 
369
+ Napi::Value Database::Tokenize(const Napi::CallbackInfo &info) {
370
+ auto env = info.Env();
371
+
372
+ if (info.Length() < 1) {
373
+ throw Napi::TypeError::New(env, "Text argument expected");
374
+ }
375
+
376
+ std::string text = info[0].As<Napi::String>();
377
+
378
+ auto tokens = duckdb::Parser::Tokenize(text);
379
+ auto numTokens = tokens.size();
380
+
381
+ auto offsets = Napi::Array::New(env, numTokens);
382
+ auto types = Napi::Array::New(env, numTokens);
383
+
384
+ for (size_t i = 0; i < numTokens; i++) {
385
+ auto token = tokens[i];
386
+ offsets.Set(i, token.start);
387
+ types.Set(i, (uint8_t)token.type);
388
+ }
389
+
390
+ auto result = Napi::Object::New(env);
391
+ result.Set("offsets", offsets);
392
+ result.Set("types", types);
393
+ return result;
394
+ }
395
+
367
396
  } // namespace node_duckdb
@@ -23,7 +23,7 @@ struct ICUMakeDate : public ICUDateFunc {
23
23
  }
24
24
 
25
25
  // Extract the time zone parts
26
- auto micros = SetTime(calendar, instant);
26
+ SetTime(calendar, instant);
27
27
  const auto era = ExtractField(calendar, UCAL_ERA);
28
28
  const auto year = ExtractField(calendar, UCAL_YEAR);
29
29
  const auto mm = ExtractField(calendar, UCAL_MONTH) + 1;
@@ -96,7 +96,6 @@ struct ICUStrptime : public ICUDateFunc {
96
96
  auto &info = func_expr.bind_info->Cast<ICUStrptimeBindData>();
97
97
  CalendarPtr calendar_ptr(info.calendar->clone());
98
98
  auto calendar = calendar_ptr.get();
99
- auto &formats = info.formats;
100
99
 
101
100
  D_ASSERT(fmt_arg.GetVectorType() == VectorType::CONSTANT_VECTOR);
102
101
 
@@ -126,7 +125,6 @@ struct ICUStrptime : public ICUDateFunc {
126
125
  auto &info = func_expr.bind_info->Cast<ICUStrptimeBindData>();
127
126
  CalendarPtr calendar_ptr(info.calendar->clone());
128
127
  auto calendar = calendar_ptr.get();
129
- auto &formats = info.formats;
130
128
 
131
129
  D_ASSERT(fmt_arg.GetVectorType() == VectorType::CONSTANT_VECTOR);
132
130
 
@@ -223,7 +223,6 @@ static void SetICUCalendar(ClientContext &context, SetScope scope, Value &parame
223
223
 
224
224
  void IcuExtension::Load(DuckDB &ddb) {
225
225
  auto &db = *ddb.instance;
226
- auto &catalog = Catalog::GetSystemCatalog(db);
227
226
 
228
227
  // iterate over all the collations
229
228
  int32_t count;