duckdb 0.7.2-dev899.0 → 0.7.2-dev921.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/lib/duckdb.d.ts CHANGED
@@ -100,7 +100,7 @@ export class Connection {
100
100
  unregister_udf(name: string, callback: Callback<any>): void;
101
101
 
102
102
  stream(sql: any, ...args: any[]): QueryResult;
103
- arrowIPCStream(sql: any, ...args: any[]): IpcResultStreamIterator;
103
+ arrowIPCStream(sql: any, ...args: any[]): Promise<IpcResultStreamIterator>;
104
104
 
105
105
  register_buffer(name: string, array: ArrowIterable, force: boolean, callback?: Callback<void>): void;
106
106
  unregister_buffer(name: string, callback?: Callback<void>): void;
package/lib/duckdb.js CHANGED
@@ -189,7 +189,7 @@ Connection.prototype.arrowIPCAll = function (sql) {
189
189
  * @arg sql
190
190
  * @param {...*} params
191
191
  * @param callback
192
- * @return IpcResultStreamIterator
192
+ * @return Promise<IpcResultStreamIterator>
193
193
  */
194
194
  Connection.prototype.arrowIPCStream = async function (sql) {
195
195
  const query = "SELECT * FROM to_arrow_ipc((" + sql + "));";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.7.2-dev899.0",
5
+ "version": "0.7.2-dev921.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -130,8 +130,10 @@ OperatorResultType PhysicalBlockwiseNLJoin::ExecuteInternal(ExecutionContext &co
130
130
  }
131
131
 
132
132
  // now perform the actual join
133
- // we perform a cross product, then execute the expression directly on the cross product' result
133
+ // we perform a cross product, then execute the expression directly on the cross product result
134
134
  idx_t result_count = 0;
135
+ bool found_match[STANDARD_VECTOR_SIZE] = {false};
136
+
135
137
  do {
136
138
  auto result = state.cross_product.Execute(input, *intermediate_chunk);
137
139
  if (result == OperatorResultType::NEED_MORE_INPUT) {
@@ -142,39 +144,58 @@ OperatorResultType PhysicalBlockwiseNLJoin::ExecuteInternal(ExecutionContext &co
142
144
  state.left_outer.ConstructLeftJoinResult(input, *intermediate_chunk);
143
145
  state.left_outer.Reset();
144
146
  }
147
+
148
+ if (join_type == JoinType::SEMI) {
149
+ PhysicalJoin::ConstructSemiJoinResult(input, chunk, found_match);
150
+ }
151
+ if (join_type == JoinType::ANTI) {
152
+ PhysicalJoin::ConstructAntiJoinResult(input, chunk, found_match);
153
+ }
154
+
145
155
  return OperatorResultType::NEED_MORE_INPUT;
146
156
  }
147
157
 
148
158
  // now perform the computation
149
159
  result_count = state.executor.SelectExpression(*intermediate_chunk, state.match_sel);
160
+
161
+ // handle anti and semi joins with different logic
150
162
  if (result_count > 0) {
151
163
  // found a match!
152
- // check if the cross product is scanning the LHS or the RHS in its entirety
153
- if (!state.cross_product.ScanLHS()) {
154
- // set the match flags in the LHS
155
- state.left_outer.SetMatches(state.match_sel, result_count);
156
- // set the match flag in the RHS
157
- gstate.right_outer.SetMatch(state.cross_product.ScanPosition() + state.cross_product.PositionInChunk());
164
+ // handle anti semi join conditions first
165
+ if (join_type == JoinType::ANTI || join_type == JoinType::SEMI) {
166
+ if (state.cross_product.ScanLHS()) {
167
+ found_match[state.cross_product.PositionInChunk()] = true;
168
+ } else {
169
+ for (idx_t i = 0; i < result_count; i++) {
170
+ found_match[state.match_sel.get_index(i)] = true;
171
+ }
172
+ }
173
+ intermediate_chunk->Reset();
174
+ // trick the loop to continue as semi and anti joins will never produce more output than
175
+ // the LHS cardinality
176
+ result_count = 0;
158
177
  } else {
159
- // set the match flag in the LHS
160
- state.left_outer.SetMatch(state.cross_product.PositionInChunk());
161
- // set the match flags in the RHS
162
- gstate.right_outer.SetMatches(state.match_sel, result_count, state.cross_product.ScanPosition());
178
+ // check if the cross product is scanning the LHS or the RHS in its entirety
179
+ if (!state.cross_product.ScanLHS()) {
180
+ // set the match flags in the LHS
181
+ state.left_outer.SetMatches(state.match_sel, result_count);
182
+ // set the match flag in the RHS
183
+ gstate.right_outer.SetMatch(state.cross_product.ScanPosition() +
184
+ state.cross_product.PositionInChunk());
185
+ } else {
186
+ // set the match flag in the LHS
187
+ state.left_outer.SetMatch(state.cross_product.PositionInChunk());
188
+ // set the match flags in the RHS
189
+ gstate.right_outer.SetMatches(state.match_sel, result_count, state.cross_product.ScanPosition());
190
+ }
191
+ intermediate_chunk->Slice(state.match_sel, result_count);
163
192
  }
164
- intermediate_chunk->Slice(state.match_sel, result_count);
165
193
  } else {
166
194
  // no result: reset the chunk
167
195
  intermediate_chunk->Reset();
168
196
  }
169
197
  } while (result_count == 0);
170
198
 
171
- if (join_type == JoinType::SEMI || join_type == JoinType::ANTI) {
172
- for (idx_t col_idx = 0; col_idx < chunk.ColumnCount(); col_idx++) {
173
- chunk.data[col_idx].Reference(intermediate_chunk->data[col_idx]);
174
- }
175
- chunk.SetCardinality(*intermediate_chunk);
176
- }
177
-
178
199
  return OperatorResultType::HAVE_MORE_OUTPUT;
179
200
  }
180
201
 
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.7.2-dev899"
2
+ #define DUCKDB_VERSION "0.7.2-dev921"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "88b1bfa74d"
5
+ #define DUCKDB_SOURCE_ID "227bd4bddc"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -60,10 +60,12 @@ public:
60
60
 
61
61
  OperatorResultType Execute(DataChunk &input, DataChunk &output);
62
62
 
63
+ // returns if the left side is scanned as a constant vector
63
64
  bool ScanLHS() {
64
65
  return scan_input_chunk;
65
66
  }
66
67
 
68
+ // returns the position in the chunk of chunk scanned as a constant input vector
67
69
  idx_t PositionInChunk() {
68
70
  return position_in_chunk;
69
71
  }