Skip to content

Commit

Permalink
Merge branch 'main' into snappy_stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lnkuiper committed Sep 16, 2024
2 parents fc1cb80 + 2d0842b commit 5a67a6a
Show file tree
Hide file tree
Showing 28 changed files with 279 additions and 95 deletions.
3 changes: 1 addition & 2 deletions .github/config/out_of_tree_extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ endif()
duckdb_extension_load(spatial
DONT_LINK LOAD_TESTS
GIT_URL https://github.com/duckdb/duckdb_spatial.git
GIT_TAG 58e0fcd09f2306803da36c4b1e8a66bb1e263316
GIT_TAG 4107eb788f933c9e268b52f6f927a6b36b9ea440
INCLUDE_DIR spatial/include
TEST_DIR test/sql
APPLY_PATCHES
)

################# SQLITE_SCANNER
Expand Down
24 changes: 0 additions & 24 deletions .github/patches/extensions/spatial/buffer_manager_allocate.patch

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/InternalIssuesCreateMirror.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Create or Label Mirror Issue
on:
discussion:
types:
- labeled
issues:
types:
- labeled
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/InternalIssuesUpdateMirror.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Update Mirror Issue
on:
discussion:
types:
- labeled
issues:
types:
- closed
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/NeedsDocumentation.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Create Documentation issue for the Needs Documentation label
on:
discussion:
types:
- labeled
issues:
types:
- labeled
Expand Down
36 changes: 18 additions & 18 deletions .github/workflows/OSX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,6 @@ jobs:
shell: bash
run: ./build/release/duckdb -c "PRAGMA platform;"

- name: Unit Test
shell: bash
if: ${{ inputs.skip_tests != 'true' }}
run: make allunit

- name: Tools Tests
shell: bash
if: ${{ inputs.skip_tests != 'true' }}
run: |
python -m pytest tools/shell/tests --shell-binary build/release/duckdb
- name: Examples
shell: bash
if: ${{ inputs.skip_tests != 'true' }}
run: |
(cd examples/embedded-c; make)
(cd examples/embedded-c++; make)
# from https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
- name: Sign Binaries
shell: bash
Expand Down Expand Up @@ -187,6 +169,24 @@ jobs:
libduckdb-osx-universal.zip
duckdb_cli-osx-universal.zip
- name: Unit Test
shell: bash
if: ${{ inputs.skip_tests != 'true' }}
run: make allunit

- name: Tools Tests
shell: bash
if: ${{ inputs.skip_tests != 'true' }}
run: |
python -m pytest tools/shell/tests --shell-binary build/release/duckdb
- name: Examples
shell: bash
if: ${{ inputs.skip_tests != 'true' }}
run: |
(cd examples/embedded-c; make)
(cd examples/embedded-c++; make)
xcode-extensions:
# Builds extensions for osx_arm64 and osx_amd64
name: OSX Extensions Release
Expand Down
2 changes: 2 additions & 0 deletions scripts/generate_extensions_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,10 @@ def write_header(data: ExtensionData):
{"s3/credential_chain", "aws"},
{"gcs/credential_chain", "aws"},
{"r2/credential_chain", "aws"},
{"azure/access_token", "azure"},
{"azure/config", "azure"},
{"azure/credential_chain", "azure"},
{"azure/service_principal", "azure"},
{"huggingface/config", "httfps"},
{"huggingface/credential_chain", "httpfs"},
{"bearer/config", "httpfs"}
Expand Down
2 changes: 1 addition & 1 deletion src/common/types/bit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void Bit::BitToBlob(string_t bit, string_t &output_blob) {
idx_t size = output_blob.GetSize();

output[0] = UnsafeNumericCast<char>(GetFirstByte(bit));
if (size > 2) {
if (size >= 2) {
++output;
// First byte in bitstring contains amount of padded bits,
// second byte in bitstring is the padded byte,
Expand Down
3 changes: 2 additions & 1 deletion src/core_functions/aggregate/distributive/minmax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "duckdb/common/vector_operations/vector_operations.hpp"
#include "duckdb/common/operator/comparison_operators.hpp"
#include "duckdb/common/types/null_value.hpp"
#include "duckdb/main/config.hpp"
#include "duckdb/planner/expression.hpp"
#include "duckdb/planner/expression/bound_comparison_expression.hpp"
#include "duckdb/planner/expression_binder.hpp"
Expand Down Expand Up @@ -330,7 +331,7 @@ unique_ptr<FunctionData> BindMinMax(ClientContext &context, AggregateFunction &f
vector<unique_ptr<Expression>> &arguments) {
if (arguments[0]->return_type.id() == LogicalTypeId::VARCHAR) {
auto str_collation = StringType::GetCollation(arguments[0]->return_type);
if (!str_collation.empty()) {
if (!str_collation.empty() || !DBConfig::GetConfig(context).options.collation.empty()) {
// If aggr function is min/max and uses collations, replace bound_function with arg_min/arg_max
// to make sure the result's correctness.
string function_name = function.name == "min" ? "arg_min" : "arg_max";
Expand Down
17 changes: 12 additions & 5 deletions src/include/duckdb/main/extension_entries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,18 @@ static constexpr ExtensionEntry EXTENSION_SECRET_TYPES[] = {
// Note: these are currently hardcoded in scripts/generate_extensions_function.py
// TODO: automate by passing though to script via duckdb
static constexpr ExtensionEntry EXTENSION_SECRET_PROVIDERS[] = {
{"s3/config", "httpfs"}, {"gcs/config", "httpfs"},
{"r2/config", "httpfs"}, {"s3/credential_chain", "aws"},
{"gcs/credential_chain", "aws"}, {"r2/credential_chain", "aws"},
{"azure/config", "azure"}, {"azure/credential_chain", "azure"},
{"huggingface/config", "httfps"}, {"huggingface/credential_chain", "httpfs"},
{"s3/config", "httpfs"},
{"gcs/config", "httpfs"},
{"r2/config", "httpfs"},
{"s3/credential_chain", "aws"},
{"gcs/credential_chain", "aws"},
{"r2/credential_chain", "aws"},
{"azure/access_token", "azure"},
{"azure/config", "azure"},
{"azure/credential_chain", "azure"},
{"azure/service_principal", "azure"},
{"huggingface/config", "httfps"},
{"huggingface/credential_chain", "httpfs"},
{"bearer/config", "httpfs"}}; // EXTENSION_SECRET_PROVIDERS

static constexpr const char *AUTOLOADABLE_EXTENSIONS[] = {
Expand Down
2 changes: 1 addition & 1 deletion src/include/duckdb/planner/expression_binder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class ExpressionBinder {
const optional_ptr<bind_lambda_function_t> bind_lambda_function,
const LogicalType &list_child_type);

static unique_ptr<ParsedExpression> GetSQLValueFunction(const string &column_name);
virtual unique_ptr<ParsedExpression> GetSQLValueFunction(const string &column_name);

LogicalType ResolveOperatorType(OperatorExpression &op, vector<unique_ptr<Expression>> &children);
LogicalType ResolveCoalesceType(OperatorExpression &op, vector<unique_ptr<Expression>> &children);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class SelectBinder : public BaseSelectBinder {
BindResult BindColumnRef(unique_ptr<ParsedExpression> &expr_ptr, idx_t depth, bool root_expression) override;

bool QualifyColumnAlias(const ColumnRefExpression &colref) override;
unique_ptr<ParsedExpression> GetSQLValueFunction(const string &column_name) override;

protected:
idx_t unnest_level = 0;
Expand Down
21 changes: 13 additions & 8 deletions src/main/extension/extension_install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,20 @@ static unique_ptr<ExtensionInstallInfo> DirectInstallExtension(DatabaseInstance
const string &local_extension_path,
ExtensionInstallOptions &options,
optional_ptr<ClientContext> context) {
string file = fs.ConvertSeparators(path);

// Try autoloading httpfs for loading extensions over https
if (context) {
auto &db = DatabaseInstance::GetDatabase(*context);
if (StringUtil::StartsWith(path, "https://") && !db.ExtensionIsLoaded("httpfs") &&
db.config.options.autoload_known_extensions) {
ExtensionHelper::AutoLoadExtension(*context, "httpfs");
string extension;
string file;
if (fs.IsRemoteFile(path, extension)) {
file = path;
// Try autoloading httpfs for loading extensions over https
if (context) {
auto &db = DatabaseInstance::GetDatabase(*context);
if (extension == "httpfs" && !db.ExtensionIsLoaded("httpfs") &&
db.config.options.autoload_known_extensions) {
ExtensionHelper::AutoLoadExtension(*context, "httpfs");
}
}
} else {
file = fs.ConvertSeparators(path);
}

// Check if file exists
Expand Down
9 changes: 9 additions & 0 deletions src/planner/expression_binder/select_binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ SelectBinder::SelectBinder(Binder &binder, ClientContext &context, BoundSelectNo
: BaseSelectBinder(binder, context, node, info) {
}

unique_ptr<ParsedExpression> SelectBinder::GetSQLValueFunction(const string &column_name) {
auto alias_entry = node.bind_state.alias_map.find(column_name);
if (alias_entry != node.bind_state.alias_map.end()) {
// don't replace SQL value functions if they are in the alias map
return nullptr;
}
return ExpressionBinder::GetSQLValueFunction(column_name);
}

BindResult SelectBinder::BindColumnRef(unique_ptr<ParsedExpression> &expr_ptr, idx_t depth, bool root_expression) {
// first try to bind the column reference regularly
auto result = BaseSelectBinder::BindColumnRef(expr_ptr, depth, root_expression);
Expand Down
38 changes: 38 additions & 0 deletions test/fuzzer/duckfuzz/regex_syntax_2889.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# name: test/fuzzer/duckfuzz/regex_syntax_2889.test
# description: Test REGEX syntax
# group: [duckfuzz]

query I
SELECT 42
----
42

query I
SELECT 42
----
<REGEX>:42

query I
SELECT 42
----
<REGEX>:.*

query I
SELECT 42
----
<!REGEX>:quack

statement error
SELECT
----
SELECT clause without selection list

statement error
SELECT
----
<REGEX>:Parser Error.*clause without selection list.*

statement error
SELECT
----
<!REGEX>:Parser Error
37 changes: 37 additions & 0 deletions test/issues/general/test_13824.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# name: test/issues/general/test_13824.test
# description: min() and max() should use default collation
# group: [general]

require icu

statement ok
PRAGMA enable_verification

statement ok
create table test(id int, name text)

statement ok
insert into test values (1, 'a'), (2, 'b'), (3, 'c'), (4, 'A'), (5, 'G'), (6, 'd')

query I
select min(name) from test
----
A

query I
select max(name) from test
----
d

statement ok
set default_collation = 'EN_US';

query I
select min(name) from test
----
a

query I
select max(name) from test
----
G
10 changes: 10 additions & 0 deletions test/sql/cast/test_bit_cast.test
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ SELECT '1111'::BIT::BLOB;
----
\x0F

query I
select 'ab'::BLOB::BIT::BLOB;
----
ab

query I
select 'a'::BLOB::BIT::BLOB;
----
a

query I
SELECT bitstring('1111', 33)::BLOB;
----
Expand Down
13 changes: 13 additions & 0 deletions test/sql/parser/test_value_functions.test
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,16 @@ group by one
having max(cast('1000-05-01 00:00:00' as timestamp)) <= current_timestamp;
----
1 1000-05-01 00:00:00

query II
select a as "b", "b" + 1 from (VALUES (84), (42)) t(a) ORDER BY ALL;
----
42 43
84 85

# value function conflict in ORDER BY
query I
select a as "CURRENT_TIMESTAMP" from (VALUES (84), (42)) t(a) order by "CURRENT_TIMESTAMP" + 1;
----
42
84
9 changes: 4 additions & 5 deletions test/sqlite/result_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ bool TestResultHelper::CheckStatementResult(const Statement &statement, ExecuteC
bool success = false;
if (StringUtil::StartsWith(statement.expected_error, "<REGEX>:") ||
StringUtil::StartsWith(statement.expected_error, "<!REGEX>:")) {
success = MatchesRegex(logger, result, statement.expected_error);
success = MatchesRegex(logger, result.ToString(), statement.expected_error);
}
if (!success) {
logger.ExpectedErrorMismatch(statement.expected_error, result);
Expand Down Expand Up @@ -450,7 +450,7 @@ bool TestResultHelper::CompareValues(SQLLogicTestLogger &logger, MaterializedQue
return true;
}
if (StringUtil::StartsWith(rvalue_str, "<REGEX>:") || StringUtil::StartsWith(rvalue_str, "<!REGEX>:")) {
if (MatchesRegex(logger, result, rvalue_str)) {
if (MatchesRegex(logger, lvalue_str, rvalue_str)) {
return true;
}
}
Expand Down Expand Up @@ -521,7 +521,7 @@ bool TestResultHelper::CompareValues(SQLLogicTestLogger &logger, MaterializedQue
return true;
}

bool TestResultHelper::MatchesRegex(SQLLogicTestLogger &logger, MaterializedQueryResult &result, string rvalue_str) {
bool TestResultHelper::MatchesRegex(SQLLogicTestLogger &logger, string lvalue_str, string rvalue_str) {
bool want_match = StringUtil::StartsWith(rvalue_str, "<REGEX>:");
string regex_str = StringUtil::Replace(StringUtil::Replace(rvalue_str, "<REGEX>:", ""), "<!REGEX>:", "");

Expand All @@ -536,8 +536,7 @@ bool TestResultHelper::MatchesRegex(SQLLogicTestLogger &logger, MaterializedQuer
logger.PrintLineSep();
return false;
}
auto resString = result.ToString();
bool regex_matches = RE2::FullMatch(result.ToString(), re);
bool regex_matches = RE2::FullMatch(lvalue_str, re);
if ((want_match && regex_matches) || (!want_match && !regex_matches)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion test/sqlite/result_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TestResultHelper {
static bool ResultIsHash(const string &result);
static bool ResultIsFile(string result);

bool MatchesRegex(SQLLogicTestLogger &logger, MaterializedQueryResult &result, string rvalue_str);
bool MatchesRegex(SQLLogicTestLogger &logger, string lvalue_str, string rvalue_str);
bool CompareValues(SQLLogicTestLogger &logger, MaterializedQueryResult &result, string lvalue_str,
string rvalue_str, idx_t current_row, idx_t current_column, vector<string> &values,
idx_t expected_column_count, bool row_wise, vector<string> &result_values);
Expand Down
Loading

0 comments on commit 5a67a6a

Please sign in to comment.