duckdb 0.3.2-dev1259.0 → 0.3.2-dev1262.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.3.2-dev1259.0",
4
+ "version": "0.3.2-dev1262.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -100463,13 +100463,15 @@ class SelectStatement;
100463
100463
 
100464
100464
  class QueryRelation : public Relation {
100465
100465
  public:
100466
- QueryRelation(ClientContext &context, string query, string alias = "query_relation");
100466
+ QueryRelation(ClientContext &context, unique_ptr<SelectStatement> select_stmt, string alias);
100467
+ ~QueryRelation();
100467
100468
 
100468
- string query;
100469
+ unique_ptr<SelectStatement> select_stmt;
100469
100470
  string alias;
100470
100471
  vector<ColumnDefinition> columns;
100471
100472
 
100472
100473
  public:
100474
+ static unique_ptr<SelectStatement> ParseStatement(ClientContext &context, const string &query, const string &error);
100473
100475
  unique_ptr<QueryNode> GetQueryNode() override;
100474
100476
  unique_ptr<TableRef> GetTableRef() override;
100475
100477
 
@@ -100915,8 +100917,12 @@ unordered_set<string> Connection::GetTableNames(const string &query) {
100915
100917
  return context->GetTableNames(query);
100916
100918
  }
100917
100919
 
100918
- shared_ptr<Relation> Connection::RelationFromQuery(const string &query, const string &alias) {
100919
- return make_shared<QueryRelation>(*context, query, alias);
100920
+ shared_ptr<Relation> Connection::RelationFromQuery(const string &query, string alias, const string &error) {
100921
+ return RelationFromQuery(QueryRelation::ParseStatement(*context, query, error), move(alias));
100922
+ }
100923
+
100924
+ shared_ptr<Relation> Connection::RelationFromQuery(unique_ptr<SelectStatement> select_stmt, string alias) {
100925
+ return make_shared<QueryRelation>(*context, move(select_stmt), move(alias));
100920
100926
  }
100921
100927
 
100922
100928
  void Connection::BeginTransaction() {
@@ -111513,23 +111519,31 @@ string ProjectionRelation::ToString(idx_t depth) {
111513
111519
 
111514
111520
  namespace duckdb {
111515
111521
 
111516
- QueryRelation::QueryRelation(ClientContext &context, string query, string alias)
111517
- : Relation(context, RelationType::QUERY_RELATION), query(move(query)), alias(move(alias)) {
111522
+ QueryRelation::QueryRelation(ClientContext &context, unique_ptr<SelectStatement> select_stmt_p, string alias_p)
111523
+ : Relation(context, RelationType::QUERY_RELATION), select_stmt(move(select_stmt_p)), alias(move(alias_p)) {
111518
111524
  context.TryBindRelation(*this, this->columns);
111519
111525
  }
111520
111526
 
111521
- unique_ptr<SelectStatement> QueryRelation::GetSelectStatement() {
111527
+ QueryRelation::~QueryRelation() {
111528
+ }
111529
+
111530
+ unique_ptr<SelectStatement> QueryRelation::ParseStatement(ClientContext &context, const string &query,
111531
+ const string &error) {
111522
111532
  Parser parser(context.GetParserOptions());
111523
111533
  parser.ParseQuery(query);
111524
111534
  if (parser.statements.size() != 1) {
111525
- throw ParserException("Expected a single SELECT statement");
111535
+ throw ParserException(error);
111526
111536
  }
111527
111537
  if (parser.statements[0]->type != StatementType::SELECT_STATEMENT) {
111528
- throw ParserException("Expected a single SELECT statement");
111538
+ throw ParserException(error);
111529
111539
  }
111530
111540
  return unique_ptr_cast<SQLStatement, SelectStatement>(move(parser.statements[0]));
111531
111541
  }
111532
111542
 
111543
+ unique_ptr<SelectStatement> QueryRelation::GetSelectStatement() {
111544
+ return unique_ptr_cast<SQLStatement, SelectStatement>(select_stmt->Copy());
111545
+ }
111546
+
111533
111547
  unique_ptr<QueryNode> QueryRelation::GetQueryNode() {
111534
111548
  auto select = GetSelectStatement();
111535
111549
  return move(select->node);
@@ -111549,7 +111563,7 @@ const vector<ColumnDefinition> &QueryRelation::Columns() {
111549
111563
  }
111550
111564
 
111551
111565
  string QueryRelation::ToString(idx_t depth) {
111552
- return RenderWhitespace(depth) + "Subquery [" + query + "]";
111566
+ return RenderWhitespace(depth) + "Subquery";
111553
111567
  }
111554
111568
 
111555
111569
  } // namespace duckdb
package/src/duckdb.hpp CHANGED
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
13
  #define DUCKDB_AMALGAMATION_EXTENDED 1
14
- #define DUCKDB_SOURCE_ID "c8fc68400"
15
- #define DUCKDB_VERSION "v0.3.2-dev1259"
14
+ #define DUCKDB_SOURCE_ID "477c52aed"
15
+ #define DUCKDB_VERSION "v0.3.2-dev1262"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -10905,6 +10905,7 @@ class ClientContext;
10905
10905
  class DatabaseInstance;
10906
10906
  class DuckDB;
10907
10907
  class LogicalOperator;
10908
+ class SelectStatement;
10908
10909
 
10909
10910
  typedef void (*warning_callback)(std::string);
10910
10911
 
@@ -11004,7 +11005,10 @@ public:
11004
11005
  DUCKDB_API shared_ptr<Relation> ReadCSV(const string &csv_file);
11005
11006
  DUCKDB_API shared_ptr<Relation> ReadCSV(const string &csv_file, const vector<string> &columns);
11006
11007
  //! Returns a relation from a query
11007
- DUCKDB_API shared_ptr<Relation> RelationFromQuery(const string &query, const string &alias = "queryrelation");
11008
+ DUCKDB_API shared_ptr<Relation> RelationFromQuery(const string &query, string alias = "queryrelation",
11009
+ const string &error = "Expected a single SELECT statement");
11010
+ DUCKDB_API shared_ptr<Relation> RelationFromQuery(unique_ptr<SelectStatement> select_stmt,
11011
+ string alias = "queryrelation");
11008
11012
 
11009
11013
  DUCKDB_API void BeginTransaction();
11010
11014
  DUCKDB_API void Commit();