duckdb 0.9.1-dev97.0 → 0.9.1

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 (83) hide show
  1. package/.github/workflows/NodeJS.yml +250 -0
  2. package/Makefile +3 -9
  3. package/README.md +2 -2
  4. package/binding.gyp +8 -8
  5. package/package.json +4 -4
  6. package/scripts/install_node.sh +21 -0
  7. package/scripts/node_build.sh +40 -0
  8. package/scripts/node_build_win.sh +21 -0
  9. package/scripts/node_version.sh +33 -0
  10. package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
  11. package/src/duckdb/extension/icu/icu-strptime.cpp +0 -2
  12. package/src/duckdb/extension/icu/icu_extension.cpp +0 -1
  13. package/src/duckdb/extension/json/json_functions/json_create.cpp +27 -14
  14. package/src/duckdb/extension/json/json_functions/json_transform.cpp +26 -14
  15. package/src/duckdb/extension/json/json_functions.cpp +1 -10
  16. package/src/duckdb/extension/parquet/column_reader.cpp +26 -1
  17. package/src/duckdb/extension/parquet/column_writer.cpp +10 -1
  18. package/src/duckdb/extension/parquet/include/column_reader.hpp +2 -0
  19. package/src/duckdb/extension/parquet/include/parquet_bss_decoder.hpp +49 -0
  20. package/src/duckdb/extension/parquet/parquet_extension.cpp +3 -4
  21. package/src/duckdb/extension/parquet/parquet_timestamp.cpp +3 -4
  22. package/src/duckdb/src/common/arrow/appender/list_data.cpp +2 -2
  23. package/src/duckdb/src/common/arrow/appender/map_data.cpp +15 -10
  24. package/src/duckdb/src/common/arrow/appender/struct_data.cpp +2 -2
  25. package/src/duckdb/src/common/arrow/appender/union_data.cpp +2 -2
  26. package/src/duckdb/src/common/arrow/arrow_appender.cpp +26 -7
  27. package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +3 -3
  28. package/src/duckdb/src/common/exception.cpp +60 -84
  29. package/src/duckdb/src/common/preserved_error.cpp +20 -0
  30. package/src/duckdb/src/common/types/data_chunk.cpp +1 -1
  31. package/src/duckdb/src/execution/expression_executor/execute_reference.cpp +1 -1
  32. package/src/duckdb/src/execution/expression_executor_state.cpp +8 -2
  33. package/src/duckdb/src/execution/operator/csv_scanner/buffered_csv_reader.cpp +1 -1
  34. package/src/duckdb/src/execution/operator/csv_scanner/csv_state_machine_cache.cpp +2 -0
  35. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp +5 -5
  36. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +4 -4
  37. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_replacement.cpp +2 -2
  38. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +1 -4
  39. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +2 -4
  40. package/src/duckdb/src/function/function_binder.cpp +1 -1
  41. package/src/duckdb/src/function/table/arrow_conversion.cpp +2 -1
  42. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  43. package/src/duckdb/src/include/duckdb/common/arrow/appender/append_data.hpp +4 -0
  44. package/src/duckdb/src/include/duckdb/common/arrow/appender/enum_data.hpp +3 -1
  45. package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +2 -1
  46. package/src/duckdb/src/include/duckdb/common/arrow/arrow_wrapper.hpp +3 -0
  47. package/src/duckdb/src/include/duckdb/common/exception.hpp +1 -0
  48. package/src/duckdb/src/include/duckdb/common/preserved_error.hpp +1 -3
  49. package/src/duckdb/src/include/duckdb/execution/expression_executor_state.hpp +1 -1
  50. package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/base_csv_reader.hpp +0 -4
  51. package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_sniffer.hpp +10 -10
  52. package/src/duckdb/src/include/duckdb/function/replacement_scan.hpp +20 -0
  53. package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
  54. package/src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp +2 -0
  55. package/src/duckdb/src/include/duckdb/planner/binder.hpp +1 -0
  56. package/src/duckdb/src/include/duckdb/planner/bound_parameter_map.hpp +3 -0
  57. package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +2 -2
  58. package/src/duckdb/src/main/capi/arrow-c.cpp +7 -4
  59. package/src/duckdb/src/main/config.cpp +14 -0
  60. package/src/duckdb/src/main/extension/extension_install.cpp +14 -12
  61. package/src/duckdb/src/optimizer/filter_pushdown.cpp +1 -0
  62. package/src/duckdb/src/optimizer/pushdown/pushdown_distinct.cpp +19 -0
  63. package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +4 -2
  64. package/src/duckdb/src/parser/transform/statement/transform_create_sequence.cpp +10 -5
  65. package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +5 -7
  66. package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +4 -2
  67. package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +17 -14
  68. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +5 -12
  69. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +15 -1
  70. package/src/duckdb/src/planner/bound_parameter_map.cpp +16 -5
  71. package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +2 -5
  72. package/src/duckdb/src/planner/planner.cpp +1 -1
  73. package/src/duckdb/src/transaction/duck_transaction_manager.cpp +13 -9
  74. package/src/duckdb/third_party/parquet/parquet_types.h +2 -1
  75. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +5 -5
  76. package/src/duckdb/ub_src_optimizer_pushdown.cpp +2 -0
  77. package/src/statement.cpp +4 -4
  78. package/test/arrow.test.ts +3 -1
  79. package/test/parquet.test.ts +1 -1
  80. package/test/userdata1.parquet +0 -0
  81. package/{configure → vendor} +1 -1
  82. package/{configure.py → vendor.py} +12 -1
  83. package/duckdb_extension_config.cmake +0 -10
@@ -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/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/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.1",
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
@@ -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;
@@ -682,20 +682,33 @@ BoundCastInfo AnyToJSONCastBind(BindCastInput &input, const LogicalType &source,
682
682
  }
683
683
 
684
684
  void JSONFunctions::RegisterJSONCreateCastFunctions(CastFunctionSet &casts) {
685
- auto json_to_any_cost = casts.ImplicitCastCost(LogicalType::ANY, JSONCommon::JSONType());
686
- casts.RegisterCastFunction(LogicalType::ANY, JSONCommon::JSONType(), AnyToJSONCastBind, json_to_any_cost);
687
-
688
- const auto struct_type = LogicalType::STRUCT({{"any", LogicalType::ANY}});
689
- auto struct_to_json_cost = casts.ImplicitCastCost(struct_type, LogicalType::VARCHAR) - 2;
690
- casts.RegisterCastFunction(struct_type, JSONCommon::JSONType(), AnyToJSONCastBind, struct_to_json_cost);
691
-
692
- const auto list_type = LogicalType::LIST(LogicalType::ANY);
693
- auto list_to_json_cost = casts.ImplicitCastCost(list_type, LogicalType::VARCHAR) - 2;
694
- casts.RegisterCastFunction(list_type, JSONCommon::JSONType(), AnyToJSONCastBind, list_to_json_cost);
695
-
696
- const auto map_type = LogicalType::MAP(LogicalType::ANY, LogicalType::ANY);
697
- auto map_to_json_cost = casts.ImplicitCastCost(map_type, LogicalType::VARCHAR) - 2;
698
- casts.RegisterCastFunction(map_type, JSONCommon::JSONType(), AnyToJSONCastBind, map_to_json_cost);
685
+ // Anything can be cast to JSON
686
+ for (const auto &type : LogicalType::AllTypes()) {
687
+ LogicalType source_type;
688
+ switch (type.id()) {
689
+ case LogicalTypeId::STRUCT:
690
+ source_type = LogicalType::STRUCT({{"any", LogicalType::ANY}});
691
+ break;
692
+ case LogicalTypeId::LIST:
693
+ source_type = LogicalType::LIST(LogicalType::ANY);
694
+ break;
695
+ case LogicalTypeId::MAP:
696
+ source_type = LogicalType::MAP(LogicalType::ANY, LogicalType::ANY);
697
+ break;
698
+ case LogicalTypeId::UNION:
699
+ source_type = LogicalType::UNION({{"any", LogicalType::ANY}});
700
+ break;
701
+ case LogicalTypeId::VARCHAR:
702
+ // We skip this one here as it's handled in json_functions.cpp
703
+ continue;
704
+ default:
705
+ source_type = type;
706
+ }
707
+ // We prefer going to JSON over going to VARCHAR if a function can do either
708
+ const auto source_to_json_cost =
709
+ MaxValue<int64_t>(casts.ImplicitCastCost(source_type, LogicalType::VARCHAR) - 1, 0);
710
+ casts.RegisterCastFunction(source_type, JSONCommon::JSONType(), AnyToJSONCastBind, source_to_json_cost);
711
+ }
699
712
  }
700
713
 
701
714
  } // namespace duckdb
@@ -898,20 +898,32 @@ BoundCastInfo JSONToAnyCastBind(BindCastInput &input, const LogicalType &source,
898
898
  }
899
899
 
900
900
  void JSONFunctions::RegisterJSONTransformCastFunctions(CastFunctionSet &casts) {
901
- auto json_to_any_cost = casts.ImplicitCastCost(JSONCommon::JSONType(), LogicalType::ANY);
902
- casts.RegisterCastFunction(JSONCommon::JSONType(), LogicalType::ANY, JSONToAnyCastBind, json_to_any_cost);
903
-
904
- const auto struct_type = LogicalType::STRUCT({{"any", LogicalType::ANY}});
905
- auto json_to_struct_cost = casts.ImplicitCastCost(LogicalType::VARCHAR, struct_type) - 2;
906
- casts.RegisterCastFunction(JSONCommon::JSONType(), struct_type, JSONToAnyCastBind, json_to_struct_cost);
907
-
908
- const auto list_type = LogicalType::LIST(LogicalType::ANY);
909
- auto json_to_list_cost = casts.ImplicitCastCost(LogicalType::VARCHAR, list_type) - 2;
910
- casts.RegisterCastFunction(JSONCommon::JSONType(), list_type, JSONToAnyCastBind, json_to_list_cost);
911
-
912
- const auto map_type = LogicalType::MAP(LogicalType::ANY, LogicalType::ANY);
913
- auto json_to_map_cost = casts.ImplicitCastCost(LogicalType::VARCHAR, map_type) - 2;
914
- casts.RegisterCastFunction(JSONCommon::JSONType(), map_type, JSONToAnyCastBind, json_to_map_cost);
901
+ // JSON can be cast to anything
902
+ for (const auto &type : LogicalType::AllTypes()) {
903
+ LogicalType target_type;
904
+ switch (type.id()) {
905
+ case LogicalTypeId::STRUCT:
906
+ target_type = LogicalType::STRUCT({{"any", LogicalType::ANY}});
907
+ break;
908
+ case LogicalTypeId::LIST:
909
+ target_type = LogicalType::LIST(LogicalType::ANY);
910
+ break;
911
+ case LogicalTypeId::MAP:
912
+ target_type = LogicalType::MAP(LogicalType::ANY, LogicalType::ANY);
913
+ break;
914
+ case LogicalTypeId::UNION:
915
+ target_type = LogicalType::UNION({{"any", LogicalType::ANY}});
916
+ break;
917
+ case LogicalTypeId::VARCHAR:
918
+ // We skip this one here as it's handled in json_functions.cpp
919
+ continue;
920
+ default:
921
+ target_type = type;
922
+ }
923
+ // Going from JSON to another type has the same cost as going from VARCHAR to that type
924
+ const auto json_to_target_cost = casts.ImplicitCastCost(LogicalType::VARCHAR, target_type);
925
+ casts.RegisterCastFunction(JSONCommon::JSONType(), target_type, JSONToAnyCastBind, json_to_target_cost);
926
+ }
915
927
  }
916
928
 
917
929
  } // namespace duckdb
@@ -189,16 +189,7 @@ vector<TableFunctionSet> JSONFunctions::GetTableFunctions() {
189
189
 
190
190
  unique_ptr<TableRef> JSONFunctions::ReadJSONReplacement(ClientContext &context, const string &table_name,
191
191
  ReplacementScanData *data) {
192
- auto lower_name = StringUtil::Lower(table_name);
193
- // remove any compression
194
- if (StringUtil::EndsWith(lower_name, ".gz")) {
195
- lower_name = lower_name.substr(0, lower_name.size() - 3);
196
- } else if (StringUtil::EndsWith(lower_name, ".zst")) {
197
- lower_name = lower_name.substr(0, lower_name.size() - 4);
198
- }
199
- if (!StringUtil::EndsWith(lower_name, ".json") && !StringUtil::Contains(lower_name, ".json?") &&
200
- !StringUtil::EndsWith(lower_name, ".jsonl") && !StringUtil::Contains(lower_name, ".jsonl?") &&
201
- !StringUtil::EndsWith(lower_name, ".ndjson") && !StringUtil::Contains(lower_name, ".ndjson?")) {
192
+ if (!ReplacementScan::CanReplace(table_name, {"json", "jsonl", "ndjson"})) {
202
193
  return nullptr;
203
194
  }
204
195
  auto table_function = make_uniq<TableFunctionRef>();