duckdb 0.4.1-dev47.0 → 0.4.1-dev487.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.
- package/Makefile +2 -2
- package/binding.gyp +8 -5
- package/lib/duckdb.js +92 -64
- package/package.json +1 -1
- package/src/connection.cpp +92 -119
- package/src/data_chunk.cpp +185 -0
- package/src/database.cpp +49 -15
- package/src/duckdb.cpp +43334 -14784
- package/src/duckdb.hpp +3873 -2235
- package/src/duckdb_node.hpp +20 -17
- package/src/parquet-amalgamation.cpp +30520 -30039
- package/src/parquet-amalgamation.hpp +95 -104
- package/src/statement.cpp +17 -12
- package/test/extension.test.js +1 -1
- package/test/udf.test.js +172 -107
|
@@ -91,8 +91,8 @@ public:
|
|
|
91
91
|
* under the License.
|
|
92
92
|
*/
|
|
93
93
|
|
|
94
|
-
#ifndef
|
|
95
|
-
#define
|
|
94
|
+
#ifndef _DUCKDB_THRIFT_THRIFT_H_
|
|
95
|
+
#define _DUCKDB_THRIFT_THRIFT_H_ 1
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
|
|
@@ -121,8 +121,8 @@ public:
|
|
|
121
121
|
|
|
122
122
|
// clang-format off
|
|
123
123
|
|
|
124
|
-
#ifndef
|
|
125
|
-
# define
|
|
124
|
+
#ifndef _DUCKDB_THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
|
|
125
|
+
# define _DUCKDB_THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
|
|
126
126
|
|
|
127
127
|
#ifdef _WIN32
|
|
128
128
|
#ifdef _WINSOCKAPI_
|
|
@@ -236,7 +236,7 @@ public:
|
|
|
236
236
|
# define THRIFT_SHUT_RDWR SHUT_RDWR
|
|
237
237
|
#endif
|
|
238
238
|
|
|
239
|
-
#endif //
|
|
239
|
+
#endif // _DUCKDB_THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
|
|
240
240
|
|
|
241
241
|
|
|
242
242
|
// LICENSE_CHANGE_END
|
|
@@ -329,8 +329,8 @@ public:
|
|
|
329
329
|
* under the License.
|
|
330
330
|
*/
|
|
331
331
|
|
|
332
|
-
#ifndef
|
|
333
|
-
#define
|
|
332
|
+
#ifndef _DUCKDB_THRIFT_TLOGGING_H_
|
|
333
|
+
#define _DUCKDB_THRIFT_TLOGGING_H_ 1
|
|
334
334
|
|
|
335
335
|
|
|
336
336
|
|
|
@@ -454,7 +454,7 @@ public:
|
|
|
454
454
|
#define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot)
|
|
455
455
|
#endif
|
|
456
456
|
|
|
457
|
-
#endif // #ifndef
|
|
457
|
+
#endif // #ifndef _DUCKDB_THRIFT_TLOGGING_H_
|
|
458
458
|
|
|
459
459
|
|
|
460
460
|
// LICENSE_CHANGE_END
|
|
@@ -546,7 +546,7 @@ void profile_write_pprof(FILE* gen_calls_f, FILE* virtual_calls_f);
|
|
|
546
546
|
}
|
|
547
547
|
} // duckdb_apache::thrift
|
|
548
548
|
|
|
549
|
-
#endif // #ifndef
|
|
549
|
+
#endif // #ifndef _DUCKDB_THRIFT_THRIFT_H_
|
|
550
550
|
|
|
551
551
|
|
|
552
552
|
// LICENSE_CHANGE_END
|
|
@@ -576,8 +576,8 @@ void profile_write_pprof(FILE* gen_calls_f, FILE* virtual_calls_f);
|
|
|
576
576
|
* under the License.
|
|
577
577
|
*/
|
|
578
578
|
|
|
579
|
-
#ifndef
|
|
580
|
-
#define
|
|
579
|
+
#ifndef _DUCKDB_THRIFT_TAPPLICATIONEXCEPTION_H_
|
|
580
|
+
#define _DUCKDB_THRIFT_TAPPLICATIONEXCEPTION_H_ 1
|
|
581
581
|
|
|
582
582
|
|
|
583
583
|
|
|
@@ -671,7 +671,7 @@ protected:
|
|
|
671
671
|
}
|
|
672
672
|
} // duckdb_apache::thrift
|
|
673
673
|
|
|
674
|
-
#endif // #ifndef
|
|
674
|
+
#endif // #ifndef _DUCKDB_THRIFT_TAPPLICATIONEXCEPTION_H_
|
|
675
675
|
|
|
676
676
|
|
|
677
677
|
// LICENSE_CHANGE_END
|
|
@@ -701,8 +701,8 @@ protected:
|
|
|
701
701
|
* under the License.
|
|
702
702
|
*/
|
|
703
703
|
|
|
704
|
-
#ifndef
|
|
705
|
-
#define
|
|
704
|
+
#ifndef _DUCKDB_THRIFT_TBASE_H_
|
|
705
|
+
#define _DUCKDB_THRIFT_TBASE_H_ 1
|
|
706
706
|
|
|
707
707
|
|
|
708
708
|
|
|
@@ -730,8 +730,8 @@ protected:
|
|
|
730
730
|
* under the License.
|
|
731
731
|
*/
|
|
732
732
|
|
|
733
|
-
#ifndef
|
|
734
|
-
#define
|
|
733
|
+
#ifndef _DUCKDB_THRIFT_PROTOCOL_TPROTOCOL_H_
|
|
734
|
+
#define _DUCKDB_THRIFT_PROTOCOL_TPROTOCOL_H_ 1
|
|
735
735
|
|
|
736
736
|
#ifdef _WIN32
|
|
737
737
|
// Need to come before any Windows.h includes
|
|
@@ -763,8 +763,8 @@ protected:
|
|
|
763
763
|
* under the License.
|
|
764
764
|
*/
|
|
765
765
|
|
|
766
|
-
#ifndef
|
|
767
|
-
#define
|
|
766
|
+
#ifndef _DUCKDB_THRIFT_TRANSPORT_TTRANSPORT_H_
|
|
767
|
+
#define _DUCKDB_THRIFT_TRANSPORT_TTRANSPORT_H_ 1
|
|
768
768
|
|
|
769
769
|
|
|
770
770
|
|
|
@@ -792,8 +792,8 @@ protected:
|
|
|
792
792
|
* under the License.
|
|
793
793
|
*/
|
|
794
794
|
|
|
795
|
-
#ifndef
|
|
796
|
-
#define
|
|
795
|
+
#ifndef _DUCKDB_THRIFT_TRANSPORT_TTRANSPORTEXCEPTION_H_
|
|
796
|
+
#define _DUCKDB_THRIFT_TRANSPORT_TTRANSPORTEXCEPTION_H_ 1
|
|
797
797
|
|
|
798
798
|
// FUCK OFF #include <boost/numeric/conversion/cast.hpp>
|
|
799
799
|
#include <string>
|
|
@@ -878,7 +878,7 @@ protected:
|
|
|
878
878
|
}
|
|
879
879
|
} // duckdb_apache::thrift::transport
|
|
880
880
|
|
|
881
|
-
#endif // #ifndef
|
|
881
|
+
#endif // #ifndef _DUCKDB_THRIFT_TRANSPORT_TTRANSPORTEXCEPTION_H_
|
|
882
882
|
|
|
883
883
|
|
|
884
884
|
// LICENSE_CHANGE_END
|
|
@@ -1129,7 +1129,7 @@ public:
|
|
|
1129
1129
|
}
|
|
1130
1130
|
} // duckdb_apache::thrift::transport
|
|
1131
1131
|
|
|
1132
|
-
#endif // #ifndef
|
|
1132
|
+
#endif // #ifndef _DUCKDB_THRIFT_TRANSPORT_TTRANSPORT_H_
|
|
1133
1133
|
|
|
1134
1134
|
|
|
1135
1135
|
// LICENSE_CHANGE_END
|
|
@@ -1159,8 +1159,8 @@ public:
|
|
|
1159
1159
|
* under the License.
|
|
1160
1160
|
*/
|
|
1161
1161
|
|
|
1162
|
-
#ifndef
|
|
1163
|
-
#define
|
|
1162
|
+
#ifndef _DUCKDB_THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_
|
|
1163
|
+
#define _DUCKDB_THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_ 1
|
|
1164
1164
|
|
|
1165
1165
|
#include <string>
|
|
1166
1166
|
|
|
@@ -1244,7 +1244,7 @@ protected:
|
|
|
1244
1244
|
}
|
|
1245
1245
|
} // duckdb_apache::thrift::protocol
|
|
1246
1246
|
|
|
1247
|
-
#endif // #ifndef
|
|
1247
|
+
#endif // #ifndef _DUCKDB_THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_
|
|
1248
1248
|
|
|
1249
1249
|
|
|
1250
1250
|
// LICENSE_CHANGE_END
|
|
@@ -1267,37 +1267,39 @@ protected:
|
|
|
1267
1267
|
// but that doesn't work.
|
|
1268
1268
|
// For a pretty in-depth explanation of the problem, see
|
|
1269
1269
|
// http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html
|
|
1270
|
+
namespace duckdb_apache { namespace thrift {
|
|
1270
1271
|
template <typename To, typename From>
|
|
1271
1272
|
static inline To bitwise_cast(From from) {
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1273
|
+
static_assert(sizeof(From) == sizeof(To), "sizeof(From) == sizeof(To)");
|
|
1274
|
+
|
|
1275
|
+
// BAD!!! These are all broken with -O2.
|
|
1276
|
+
// return *reinterpret_cast<To*>(&from); // BAD!!!
|
|
1277
|
+
// return *static_cast<To*>(static_cast<void*>(&from)); // BAD!!!
|
|
1278
|
+
// return *(To*)(void*)&from; // BAD!!!
|
|
1279
|
+
|
|
1280
|
+
// Super clean and paritally blessed by section 3.9 of the standard.
|
|
1281
|
+
// unsigned char c[sizeof(from)];
|
|
1282
|
+
// memcpy(c, &from, sizeof(from));
|
|
1283
|
+
// To to;
|
|
1284
|
+
// memcpy(&to, c, sizeof(c));
|
|
1285
|
+
// return to;
|
|
1286
|
+
|
|
1287
|
+
// Slightly more questionable.
|
|
1288
|
+
// Same code emitted by GCC.
|
|
1289
|
+
// To to;
|
|
1290
|
+
// memcpy(&to, &from, sizeof(from));
|
|
1291
|
+
// return to;
|
|
1292
|
+
|
|
1293
|
+
// Technically undefined, but almost universally supported,
|
|
1294
|
+
// and the most efficient implementation.
|
|
1295
|
+
union {
|
|
1296
|
+
From f;
|
|
1297
|
+
To t;
|
|
1298
|
+
} u;
|
|
1299
|
+
u.f = from;
|
|
1300
|
+
return u.t;
|
|
1300
1301
|
}
|
|
1302
|
+
}} // namespace duckdb_apache::thrift
|
|
1301
1303
|
|
|
1302
1304
|
|
|
1303
1305
|
#ifdef HAVE_SYS_PARAM_H
|
|
@@ -1983,7 +1985,7 @@ uint32_t skip(Protocol_& prot, TType type) {
|
|
|
1983
1985
|
|
|
1984
1986
|
}}} // duckdb_apache::thrift::protocol
|
|
1985
1987
|
|
|
1986
|
-
#endif // #define
|
|
1988
|
+
#endif // #define _DUCKDB_THRIFT_PROTOCOL_TPROTOCOL_H_ 1
|
|
1987
1989
|
|
|
1988
1990
|
|
|
1989
1991
|
// LICENSE_CHANGE_END
|
|
@@ -2001,7 +2003,7 @@ public:
|
|
|
2001
2003
|
}
|
|
2002
2004
|
} // duckdb_apache::thrift
|
|
2003
2005
|
|
|
2004
|
-
#endif // #ifndef
|
|
2006
|
+
#endif // #ifndef _DUCKDB_THRIFT_TBASE_H_
|
|
2005
2007
|
|
|
2006
2008
|
|
|
2007
2009
|
// LICENSE_CHANGE_END
|
|
@@ -4651,8 +4653,8 @@ std::ostream& operator<<(std::ostream& out, const FileCryptoMetaData& obj);
|
|
|
4651
4653
|
* under the License.
|
|
4652
4654
|
*/
|
|
4653
4655
|
|
|
4654
|
-
#ifndef
|
|
4655
|
-
#define
|
|
4656
|
+
#ifndef _DUCKDB_THRIFT_PROTOCOL_TCOMPACTPROTOCOL_H_
|
|
4657
|
+
#define _DUCKDB_THRIFT_PROTOCOL_TCOMPACTPROTOCOL_H_ 1
|
|
4656
4658
|
|
|
4657
4659
|
|
|
4658
4660
|
|
|
@@ -4679,8 +4681,8 @@ std::ostream& operator<<(std::ostream& out, const FileCryptoMetaData& obj);
|
|
|
4679
4681
|
* under the License.
|
|
4680
4682
|
*/
|
|
4681
4683
|
|
|
4682
|
-
#ifndef
|
|
4683
|
-
#define
|
|
4684
|
+
#ifndef _DUCKDB_THRIFT_PROTOCOL_TVIRTUALPROTOCOL_H_
|
|
4685
|
+
#define _DUCKDB_THRIFT_PROTOCOL_TVIRTUALPROTOCOL_H_ 1
|
|
4684
4686
|
|
|
4685
4687
|
|
|
4686
4688
|
|
|
@@ -5172,7 +5174,7 @@ protected:
|
|
|
5172
5174
|
}
|
|
5173
5175
|
} // duckdb_apache::thrift::protocol
|
|
5174
5176
|
|
|
5175
|
-
#endif // #define
|
|
5177
|
+
#endif // #define _DUCKDB_THRIFT_PROTOCOL_TVIRTUALPROTOCOL_H_ 1
|
|
5176
5178
|
|
|
5177
5179
|
|
|
5178
5180
|
// LICENSE_CHANGE_END
|
|
@@ -5441,8 +5443,8 @@ typedef TCompactProtocolFactoryT<TTransport> TCompactProtocolFactory;
|
|
|
5441
5443
|
* specific language governing permissions and limitations
|
|
5442
5444
|
* under the License.
|
|
5443
5445
|
*/
|
|
5444
|
-
#ifndef
|
|
5445
|
-
#define
|
|
5446
|
+
#ifndef _DUCKDB_THRIFT_PROTOCOL_TCOMPACTPROTOCOL_TCC_
|
|
5447
|
+
#define _DUCKDB_THRIFT_PROTOCOL_TCOMPACTPROTOCOL_TCC_ 1
|
|
5446
5448
|
|
|
5447
5449
|
#include <limits>
|
|
5448
5450
|
|
|
@@ -6248,7 +6250,7 @@ TType TCompactProtocolT<Transport_>::getTType(int8_t type) {
|
|
|
6248
6250
|
|
|
6249
6251
|
}}} // duckdb_apache::thrift::protocol
|
|
6250
6252
|
|
|
6251
|
-
#endif //
|
|
6253
|
+
#endif // _DUCKDB_THRIFT_PROTOCOL_TCOMPACTPROTOCOL_TCC_
|
|
6252
6254
|
|
|
6253
6255
|
|
|
6254
6256
|
// LICENSE_CHANGE_END
|
|
@@ -6284,8 +6286,8 @@ TType TCompactProtocolT<Transport_>::getTType(int8_t type) {
|
|
|
6284
6286
|
* under the License.
|
|
6285
6287
|
*/
|
|
6286
6288
|
|
|
6287
|
-
#ifndef
|
|
6288
|
-
#define
|
|
6289
|
+
#ifndef _DUCKDB_THRIFT_TRANSPORT_TBUFFERTRANSPORTS_H_
|
|
6290
|
+
#define _DUCKDB_THRIFT_TRANSPORT_TBUFFERTRANSPORTS_H_ 1
|
|
6289
6291
|
|
|
6290
6292
|
#include <cstdlib>
|
|
6291
6293
|
#include <cstddef>
|
|
@@ -6319,8 +6321,8 @@ TType TCompactProtocolT<Transport_>::getTType(int8_t type) {
|
|
|
6319
6321
|
* under the License.
|
|
6320
6322
|
*/
|
|
6321
6323
|
|
|
6322
|
-
#ifndef
|
|
6323
|
-
#define
|
|
6324
|
+
#ifndef _DUCKDB_THRIFT_TRANSPORT_TVIRTUALTRANSPORT_H_
|
|
6325
|
+
#define _DUCKDB_THRIFT_TRANSPORT_TVIRTUALTRANSPORT_H_ 1
|
|
6324
6326
|
|
|
6325
6327
|
|
|
6326
6328
|
|
|
@@ -6439,7 +6441,7 @@ protected:
|
|
|
6439
6441
|
}
|
|
6440
6442
|
} // duckdb_apache::thrift::transport
|
|
6441
6443
|
|
|
6442
|
-
#endif // #ifndef
|
|
6444
|
+
#endif // #ifndef _DUCKDB_THRIFT_TRANSPORT_TVIRTUALTRANSPORT_H_
|
|
6443
6445
|
|
|
6444
6446
|
|
|
6445
6447
|
// LICENSE_CHANGE_END
|
|
@@ -6902,7 +6904,7 @@ protected:
|
|
|
6902
6904
|
}
|
|
6903
6905
|
} // duckdb_apache::thrift::transport
|
|
6904
6906
|
|
|
6905
|
-
#endif // #ifndef
|
|
6907
|
+
#endif // #ifndef _DUCKDB_THRIFT_TRANSPORT_TBUFFERTRANSPORTS_H_
|
|
6906
6908
|
|
|
6907
6909
|
|
|
6908
6910
|
// LICENSE_CHANGE_END
|
|
@@ -7734,6 +7736,8 @@ struct ParquetOptions {
|
|
|
7734
7736
|
explicit ParquetOptions(ClientContext &context);
|
|
7735
7737
|
|
|
7736
7738
|
bool binary_as_string = false;
|
|
7739
|
+
bool filename = false;
|
|
7740
|
+
bool hive_partitioning = false;
|
|
7737
7741
|
};
|
|
7738
7742
|
|
|
7739
7743
|
class ParquetReader {
|
|
@@ -7851,7 +7855,7 @@ namespace duckdb {
|
|
|
7851
7855
|
class BufferedSerializer;
|
|
7852
7856
|
class ParquetWriter;
|
|
7853
7857
|
class ColumnWriterPageState;
|
|
7854
|
-
class
|
|
7858
|
+
class BasicColumnWriterState;
|
|
7855
7859
|
|
|
7856
7860
|
class ColumnWriterState {
|
|
7857
7861
|
public:
|
|
@@ -7873,9 +7877,6 @@ public:
|
|
|
7873
7877
|
};
|
|
7874
7878
|
|
|
7875
7879
|
class ColumnWriter {
|
|
7876
|
-
//! We limit the uncompressed page size to 100MB
|
|
7877
|
-
// The max size in Parquet is 2GB, but we choose a more conservative limit
|
|
7878
|
-
static constexpr const idx_t MAX_UNCOMPRESSED_PAGE_SIZE = 100000000;
|
|
7879
7880
|
|
|
7880
7881
|
public:
|
|
7881
7882
|
ColumnWriter(ParquetWriter &writer, idx_t schema_idx, vector<string> schema_path, idx_t max_repeat,
|
|
@@ -7899,46 +7900,35 @@ public:
|
|
|
7899
7900
|
idx_t max_repeat = 0, idx_t max_define = 1,
|
|
7900
7901
|
bool can_have_nulls = true);
|
|
7901
7902
|
|
|
7902
|
-
virtual unique_ptr<ColumnWriterState> InitializeWriteState(duckdb_parquet::format::RowGroup &row_group);
|
|
7903
|
-
virtual void Prepare(ColumnWriterState &state, ColumnWriterState *parent, Vector &vector, idx_t count);
|
|
7904
|
-
|
|
7905
|
-
virtual void BeginWrite(ColumnWriterState &state);
|
|
7906
|
-
virtual void Write(ColumnWriterState &state, Vector &vector, idx_t count);
|
|
7907
|
-
virtual void FinalizeWrite(ColumnWriterState &state);
|
|
7908
|
-
|
|
7909
|
-
protected:
|
|
7910
|
-
void HandleDefineLevels(ColumnWriterState &state, ColumnWriterState *parent, ValidityMask &validity, idx_t count,
|
|
7911
|
-
uint16_t define_value, uint16_t null_value);
|
|
7912
|
-
void HandleRepeatLevels(ColumnWriterState &state_p, ColumnWriterState *parent, idx_t count, idx_t max_repeat);
|
|
7903
|
+
virtual unique_ptr<ColumnWriterState> InitializeWriteState(duckdb_parquet::format::RowGroup &row_group) = 0;
|
|
7913
7904
|
|
|
7914
|
-
|
|
7915
|
-
|
|
7905
|
+
//! indicates whether the write need to analyse the data before preparing it
|
|
7906
|
+
virtual bool HasAnalyze() {
|
|
7907
|
+
return false;
|
|
7908
|
+
}
|
|
7916
7909
|
|
|
7917
|
-
virtual
|
|
7910
|
+
virtual void Analyze(ColumnWriterState &state, ColumnWriterState *parent, Vector &vector, idx_t count) {
|
|
7911
|
+
throw NotImplementedException("Writer does not need analysis");
|
|
7912
|
+
}
|
|
7918
7913
|
|
|
7919
|
-
|
|
7920
|
-
void
|
|
7921
|
-
|
|
7914
|
+
//! Called after all data has been passed to Analyze
|
|
7915
|
+
virtual void FinalizeAnalyze(ColumnWriterState &state) {
|
|
7916
|
+
throw NotImplementedException("Writer does not need analysis");
|
|
7917
|
+
}
|
|
7922
7918
|
|
|
7923
|
-
virtual void
|
|
7919
|
+
virtual void Prepare(ColumnWriterState &state, ColumnWriterState *parent, Vector &vector, idx_t count) = 0;
|
|
7924
7920
|
|
|
7925
|
-
|
|
7926
|
-
virtual
|
|
7927
|
-
|
|
7928
|
-
virtual idx_t GetRowSize(Vector &vector, idx_t index);
|
|
7929
|
-
//! Writes a (subset of a) vector to the specified serializer. Only used for scalar types.
|
|
7930
|
-
virtual void WriteVector(Serializer &temp_writer, ColumnWriterStatistics *stats, ColumnWriterPageState *page_state,
|
|
7931
|
-
Vector &vector, idx_t chunk_start, idx_t chunk_end);
|
|
7921
|
+
virtual void BeginWrite(ColumnWriterState &state) = 0;
|
|
7922
|
+
virtual void Write(ColumnWriterState &state, Vector &vector, idx_t count) = 0;
|
|
7923
|
+
virtual void FinalizeWrite(ColumnWriterState &state) = 0;
|
|
7932
7924
|
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7925
|
+
protected:
|
|
7926
|
+
void HandleDefineLevels(ColumnWriterState &state, ColumnWriterState *parent, ValidityMask &validity, idx_t count,
|
|
7927
|
+
uint16_t define_value, uint16_t null_value);
|
|
7928
|
+
void HandleRepeatLevels(ColumnWriterState &state_p, ColumnWriterState *parent, idx_t count, idx_t max_repeat);
|
|
7937
7929
|
|
|
7938
7930
|
void CompressPage(BufferedSerializer &temp_writer, size_t &compressed_size, data_ptr_t &compressed_data,
|
|
7939
7931
|
unique_ptr<data_t[]> &compressed_buf);
|
|
7940
|
-
|
|
7941
|
-
void SetParquetStatistics(StandardColumnWriterState &state, duckdb_parquet::format::ColumnChunk &column);
|
|
7942
7932
|
};
|
|
7943
7933
|
|
|
7944
7934
|
} // namespace duckdb
|
|
@@ -7951,6 +7941,7 @@ class FileOpener;
|
|
|
7951
7941
|
|
|
7952
7942
|
class ParquetWriter {
|
|
7953
7943
|
friend class ColumnWriter;
|
|
7944
|
+
friend class BasicColumnWriter;
|
|
7954
7945
|
friend class ListColumnWriter;
|
|
7955
7946
|
friend class StructColumnWriter;
|
|
7956
7947
|
|
package/src/statement.cpp
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#include "duckdb_node.hpp"
|
|
2
2
|
|
|
3
|
+
#include <cassert>
|
|
4
|
+
|
|
3
5
|
namespace node_duckdb {
|
|
4
6
|
|
|
5
7
|
Napi::FunctionReference Statement::constructor;
|
|
@@ -10,7 +12,7 @@ Napi::Object Statement::Init(Napi::Env env, Napi::Object exports) {
|
|
|
10
12
|
Napi::Function t =
|
|
11
13
|
DefineClass(env, "Statement",
|
|
12
14
|
{InstanceMethod("run", &Statement::Run), InstanceMethod("all", &Statement::All),
|
|
13
|
-
InstanceMethod("each", &Statement::Each), InstanceMethod("finalize", &Statement::
|
|
15
|
+
InstanceMethod("each", &Statement::Each), InstanceMethod("finalize", &Statement::Finish)});
|
|
14
16
|
|
|
15
17
|
constructor = Napi::Persistent(t);
|
|
16
18
|
constructor.SuppressDestruct();
|
|
@@ -20,7 +22,7 @@ Napi::Object Statement::Init(Napi::Env env, Napi::Object exports) {
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
struct PrepareTask : public Task {
|
|
23
|
-
PrepareTask(Statement &
|
|
25
|
+
PrepareTask(Statement &statement, Napi::Function callback) : Task(statement, callback) {
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
void DoWork() override {
|
|
@@ -77,7 +79,7 @@ Statement::~Statement() {
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
// A Napi InstanceOf for Javascript Objects "Date" and "RegExp"
|
|
80
|
-
static bool
|
|
82
|
+
static bool OtherInstanceOf(Napi::Object source, const char *object_type) {
|
|
81
83
|
if (strcmp(object_type, "Date") == 0) {
|
|
82
84
|
return source.InstanceOf(source.Env().Global().Get(object_type).As<Napi::Function>());
|
|
83
85
|
} else if (strcmp(object_type, "RegExp") == 0) {
|
|
@@ -87,10 +89,10 @@ static bool other_instance_of(Napi::Object source, const char *object_type) {
|
|
|
87
89
|
return false;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
static duckdb::Value
|
|
92
|
+
static duckdb::Value BindParameter(const Napi::Value source) {
|
|
91
93
|
if (source.IsString()) {
|
|
92
94
|
return duckdb::Value(source.As<Napi::String>().Utf8Value());
|
|
93
|
-
} else if (
|
|
95
|
+
} else if (OtherInstanceOf(source.As<Napi::Object>(), "RegExp")) {
|
|
94
96
|
return duckdb::Value(source.ToString().Utf8Value());
|
|
95
97
|
} else if (source.IsNumber()) {
|
|
96
98
|
if (Utils::OtherIsInt(source.As<Napi::Number>())) {
|
|
@@ -208,6 +210,7 @@ static Napi::Value convert_chunk(Napi::Env &env, std::vector<std::string> names,
|
|
|
208
210
|
Napi::EscapableHandleScope scope(env);
|
|
209
211
|
std::vector<Napi::String> node_names;
|
|
210
212
|
assert(names.size() == chunk.ColumnCount());
|
|
213
|
+
node_names.reserve(names.size());
|
|
211
214
|
for (auto &name : names) {
|
|
212
215
|
node_names.push_back(Napi::String::New(env, name));
|
|
213
216
|
}
|
|
@@ -240,8 +243,8 @@ struct StatementParam {
|
|
|
240
243
|
};
|
|
241
244
|
|
|
242
245
|
struct RunPreparedTask : public Task {
|
|
243
|
-
RunPreparedTask(Statement &
|
|
244
|
-
: Task(
|
|
246
|
+
RunPreparedTask(Statement &statement, duckdb::unique_ptr<StatementParam> params, RunType run_type)
|
|
247
|
+
: Task(statement, params->callback), params(move(params)), run_type(run_type) {
|
|
245
248
|
}
|
|
246
249
|
|
|
247
250
|
void DoWork() override {
|
|
@@ -285,6 +288,8 @@ struct RunPreparedTask : public Task {
|
|
|
285
288
|
case RunType::EACH: {
|
|
286
289
|
duckdb::idx_t count = 0;
|
|
287
290
|
while (true) {
|
|
291
|
+
Napi::HandleScope scope(env);
|
|
292
|
+
|
|
288
293
|
auto chunk = result->Fetch();
|
|
289
294
|
if (!chunk || chunk->size() == 0) {
|
|
290
295
|
break;
|
|
@@ -352,7 +357,7 @@ duckdb::unique_ptr<StatementParam> Statement::HandleArgs(const Napi::CallbackInf
|
|
|
352
357
|
if (p.IsUndefined()) {
|
|
353
358
|
continue;
|
|
354
359
|
}
|
|
355
|
-
params->params.push_back(
|
|
360
|
+
params->params.push_back(BindParameter(p));
|
|
356
361
|
}
|
|
357
362
|
return params;
|
|
358
363
|
}
|
|
@@ -377,8 +382,8 @@ Napi::Value Statement::Each(const Napi::CallbackInfo &info) {
|
|
|
377
382
|
return info.This();
|
|
378
383
|
}
|
|
379
384
|
|
|
380
|
-
struct
|
|
381
|
-
|
|
385
|
+
struct FinishTask : public Task {
|
|
386
|
+
FinishTask(Statement &statement, Napi::Function callback) : Task(statement, callback) {
|
|
382
387
|
}
|
|
383
388
|
|
|
384
389
|
void DoWork() override {
|
|
@@ -387,7 +392,7 @@ struct FinalizeTask : public Task {
|
|
|
387
392
|
}
|
|
388
393
|
};
|
|
389
394
|
|
|
390
|
-
Napi::Value Statement::
|
|
395
|
+
Napi::Value Statement::Finish(const Napi::CallbackInfo &info) {
|
|
391
396
|
Napi::Env env = info.Env();
|
|
392
397
|
Napi::HandleScope scope(env);
|
|
393
398
|
|
|
@@ -397,7 +402,7 @@ Napi::Value Statement::Finalize_(const Napi::CallbackInfo &info) {
|
|
|
397
402
|
callback = info[0].As<Napi::Function>();
|
|
398
403
|
}
|
|
399
404
|
|
|
400
|
-
connection_ref->database_ref->Schedule(env, duckdb::make_unique<
|
|
405
|
+
connection_ref->database_ref->Schedule(env, duckdb::make_unique<FinishTask>(*this, callback));
|
|
401
406
|
return env.Null();
|
|
402
407
|
}
|
|
403
408
|
|
package/test/extension.test.js
CHANGED