Skip to content

Commit 856154f

Browse files
committed
Merge branch 'feature' into pushdown-or-operators
2 parents 05a1ae6 + 86c87e4 commit 856154f

File tree

9 files changed

+832
-675
lines changed

9 files changed

+832
-675
lines changed

extension/icu/icu-timezone.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ static void ICUTimeZoneFunction(ClientContext &context, TableFunctionInput &data
8181
break;
8282
}
8383

84+
// What PG reports is the total offset for today,
85+
// which is the ICU total offset (i.e., "raw") plus the DST offset.
86+
raw_offset_ms += dst_offset_ms;
8487
output.SetValue(2, index, Value::INTERVAL(Interval::FromMicro(raw_offset_ms * Interval::MICROS_PER_MSEC)));
8588
output.SetValue(3, index, Value(dst_offset_ms != 0));
8689
++index;

src/execution/operator/persistent/physical_copy_to_file.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CopyToFunctionGlobalState : public GlobalSinkState {
1919
idx_t rows_copied;
2020
idx_t last_file_offset;
2121
unique_ptr<GlobalFunctionData> global_state;
22-
bool created_directories = false;
22+
idx_t created_directories = 0;
2323

2424
//! shared state for HivePartitionedColumnData
2525
shared_ptr<GlobalHivePartitionState> partition_state;
@@ -122,12 +122,13 @@ SinkCombineResultType PhysicalCopyToFile::Combine(ExecutionContext &context, Ope
122122
{
123123
// create directories
124124
lock_guard<mutex> global_lock(g.lock);
125-
if (!g.created_directories) {
126-
for (idx_t i = 0; i < partitions.size(); i++) {
127-
CreateDirectories(partition_columns, names, partition_key_map[i]->values, trimmed_path, fs);
128-
}
129-
g.created_directories = true;
125+
const auto &global_partitions = g.partition_state->partitions;
126+
// global_partitions have partitions added only at the back, so it's fine to only traverse the last part
127+
128+
for (idx_t i = g.created_directories; i < global_partitions.size(); i++) {
129+
CreateDirectories(partition_columns, names, global_partitions[i]->first.values, trimmed_path, fs);
130130
}
131+
g.created_directories = global_partitions.size();
131132
}
132133

133134
for (idx_t i = 0; i < partitions.size(); i++) {

src/include/duckdb/storage/table/column_segment.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
namespace duckdb {
2222
class ColumnSegment;
2323
class BlockManager;
24-
class ColumnSegment;
2524
class ColumnData;
2625
class DatabaseInstance;
2726
class Transaction;

src/planner/binder/statement/bind_create.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,9 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
509509
case CatalogType::INDEX_ENTRY: {
510510
auto &base = stmt.info->Cast<CreateIndexInfo>();
511511

512+
auto catalog = BindCatalog(base.catalog);
513+
properties.modified_databases.insert(catalog);
514+
512515
// visit the table reference
513516
auto table_ref = make_uniq<BaseTableRef>();
514517
table_ref->catalog_name = base.catalog;

src/planner/binder/statement/bind_drop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ BoundStatement Binder::Bind(DropStatement &stmt) {
4444
}
4545
stmt.info->catalog = entry->ParentCatalog().GetName();
4646
if (!entry->temporary) {
47-
// we can only drop temporary tables in read-only mode
47+
// we can only drop temporary schema entries in read-only mode
4848
properties.modified_databases.insert(stmt.info->catalog);
4949
}
5050
stmt.info->schema = entry->ParentSchema().name;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# name: test/sql/copy/parquet/parquet_hive2.test
2+
# description: Test generating hive partitioning scheme
3+
# group: [parquet]
4+
5+
require parquet
6+
7+
# See https://github.com/duckdb/duckdb/pull/9473#issuecomment-1786231577
8+
9+
statement ok
10+
create or replace table orders(m int,v int,j int);
11+
12+
statement ok
13+
insert into orders select i%12+1,i,j from range(360)t(i),range(1000)s(j);
14+
15+
statement ok
16+
copy (select 2000+(v//12)y,m,v,j from orders) TO '__TEST_DIR__/orders_m' (FORMAT PARQUET, PARTITION_BY (m));
17+
18+
statement ok
19+
copy (select 2000+(v//12)y,m,v,j from orders) TO '__TEST_DIR__/orders_y' (FORMAT PARQUET, PARTITION_BY (y));
20+
21+
statement ok
22+
copy (select 2000+(v//12)y,m,v,j from orders) TO '__TEST_DIR__/orders_ym' (FORMAT PARQUET,PARTITION_BY (y,m));

test/sql/function/timestamp/test_icu_strptime.test

Lines changed: 126 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,43 +74,141 @@ SELECT '1582-10-10'::TIMESTAMPTZ AS ts;
7474
# Same date, multiple TZ names
7575
#
7676

77+
# We can't use the offsets in pg_timezone_names()
78+
# because they change with the date
79+
# So hard code the original values
80+
# The important point is that these cover all the GMT offsets.
7781
statement ok
7882
CREATE TABLE zones AS (
79-
SELECT median(name) as tz_name
80-
FROM pg_timezone_names()
81-
GROUP BY utc_offset
82-
ORDER BY utc_offset
83+
FROM (VALUES
84+
('Etc/GMT-14'),
85+
('NZ-CHAT'),
86+
('Pacific/Auckland'),
87+
('Pacific/Enderbury'),
88+
('Australia/LHI'),
89+
('Australia/Melbourne'),
90+
('Pacific/Efate'),
91+
('Australia/Darwin'),
92+
('Asia/Tokyo'),
93+
('Australia/Eucla'),
94+
('Asia/Shanghai'),
95+
('Asia/Novosibirsk'),
96+
('Asia/Yangon'),
97+
('Asia/Omsk'),
98+
('Asia/Kathmandu'),
99+
('Asia/Colombo'),
100+
('Asia/Oral'),
101+
('Asia/Kabul'),
102+
('Europe/Astrakhan'),
103+
('Asia/Tehran'),
104+
('Asia/Kuwait'),
105+
('Asia/Nicosia'),
106+
('Europe/Budapest'),
107+
('Etc/GMT-0'),
108+
('Atlantic/Azores'),
109+
('America/Cayenne'),
110+
('America/Nuuk'),
111+
('CNT'),
112+
('America/Martinique'),
113+
('America/Louisville'),
114+
('America/Rainy_River'),
115+
('America/Shiprock'),
116+
('Mexico/BajaNorte'),
117+
('America/Sitka'),
118+
('Pacific/Marquesas'),
119+
('Pacific/Johnston'),
120+
('Pacific/Niue'),
121+
('Etc/GMT+12'),
122+
) tbl(tz_name)
83123
);
84124

85125
statement ok
86126
CREATE TABLE abbrevs AS (
87-
SELECT median(abbrev) as tz_name
88-
FROM pg_timezone_names()
89-
GROUP BY utc_offset
90-
ORDER BY utc_offset
127+
FROM (VALUES
128+
('Etc/GMT-14'),
129+
('NZ-CHAT'),
130+
('NZ'),
131+
('Pacific/Enderbury'),
132+
('Australia/Hobart'),
133+
('Australia/LHI'),
134+
('Pacific/Efate'),
135+
('Australia/Adelaide'),
136+
('Etc/GMT-9'),
137+
('Australia/Eucla'),
138+
('CTT'),
139+
('Asia/Phnom_Penh'),
140+
('Asia/Yangon'),
141+
('Asia/Thimbu'),
142+
('Asia/Kathmandu'),
143+
('IST'),
144+
('Asia/Qyzylorda'),
145+
('Asia/Kabul'),
146+
('Europe/Samara'),
147+
('Iran'),
148+
('EAT'),
149+
('CAT'),
150+
('Europe/Bratislava'),
151+
('GMT'),
152+
('Atlantic/Azores'),
153+
('America/Cayenne'),
154+
('America/Nuuk'),
155+
('CNT'),
156+
('PRT'),
157+
('America/Panama'),
158+
('America/Rankin_Inlet'),
159+
('Canada/Yukon'),
160+
('PST'),
161+
('America/Nome'),
162+
('Pacific/Marquesas'),
163+
('Pacific/Johnston'),
164+
('Pacific/Niue'),
165+
('Etc/GMT+12'),
166+
) tbl(tz_name)
91167
);
92168

93169
statement ok
94-
CREATE TABLE offsets AS (
95-
SELECT
96-
CASE WHEN EXTRACT(MINUTE FROM utc_offset) <> 0
97-
THEN
98-
CASE WHEN utc_offset < INTERVAL 0 SECOND
99-
THEN LEFT(utc_offset, 6)
100-
ELSE '+' || LEFT(utc_offset, 5)
101-
END
102-
ELSE
103-
CASE WHEN utc_offset < INTERVAL 0 SECOND
104-
THEN LEFT(utc_offset, 3)
105-
ELSE '+' || LEFT(utc_offset, 2)
106-
END
107-
END AS utc_offset
108-
FROM (
109-
SELECT DISTINCT utc_offset
110-
FROM pg_timezone_names()
111-
ORDER BY ALL
112-
) z
113-
);
170+
CREATE TABLE offsets AS
171+
FROM (VALUES
172+
('+14'),
173+
('+13'),
174+
('+12:45'),
175+
('+12'),
176+
('+11'),
177+
('+10:30'),
178+
('+10'),
179+
('+09:30'),
180+
('+09'),
181+
('+08:45'),
182+
('+08'),
183+
('+07'),
184+
('+06:30'),
185+
('+06'),
186+
('+05:45'),
187+
('+05:30'),
188+
('+05'),
189+
('+04:30'),
190+
('+04'),
191+
('+03:30'),
192+
('+03'),
193+
('+02'),
194+
('+01'),
195+
('+00'),
196+
('-01'),
197+
('-02'),
198+
('-03'),
199+
('-03:30'),
200+
('-04'),
201+
('-05'),
202+
('-06'),
203+
('-07'),
204+
('-08'),
205+
('-09'),
206+
('-09:30'),
207+
('-10'),
208+
('-11'),
209+
('-12'),
210+
) tbl(utc_offset)
211+
;
114212

115213
foreach func strptime try_strptime
116214

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# name: test/sql/index/art/storage/test_art_readonly.test
2+
# description: Test that index creation is disabled in readonly mode
3+
# group: [storage]
4+
5+
load __TEST_DIR__/test_index.db
6+
7+
statement ok
8+
CREATE TABLE tbl (i INTEGER);
9+
10+
statement ok
11+
CREATE INDEX idx_drop ON tbl(i);
12+
13+
# try index creation in readonly
14+
15+
load __TEST_DIR__/test_index.db readonly
16+
17+
statement error
18+
CREATE INDEX idx ON tbl (i);
19+
----
20+
read-only mode
21+
22+
statement error
23+
DROP INDEX idx_drop
24+
----
25+
read-only mode
26+
27+
# ensure that we did not create another index
28+
query I
29+
SELECT index_name FROM duckdb_indexes();
30+
----
31+
idx_drop

0 commit comments

Comments
 (0)