Skip to content

Commit 5ba06ac

Browse files
authored
writing table to parquet followed by read and schema check (apache#21444)
## Which issue does this PR close? This attempts to bridge the missing test coverage mentioned by @alamb on this issue apache#8791 <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes #. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> ## Are these changes tested? The changes are test <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> ## Are there any user-facing changes? no <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
1 parent 190b104 commit 5ba06ac

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

datafusion/sqllogictest/test_files/dictionary.slt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,63 @@ CREATE TABLE test0 AS VALUES ('foo',1), ('bar',2), ('foo',3);
455455

456456
statement ok
457457
COPY (SELECT arrow_cast(column1, 'Dictionary(Int32, Utf8)') AS column1, column2 FROM test0) TO 'test_files/scratch/dictionary/part_dict_test' STORED AS PARQUET PARTITIONED BY (column1);
458+
459+
460+
# Dictionary-encoded large hashes repeated across 10 rows (3 unique hashes)
461+
statement ok
462+
CREATE TABLE dict_hash_src AS
463+
SELECT
464+
arrow_cast(column1, 'Int64') AS id,
465+
arrow_cast(column2, 'Dictionary(Int32, Utf8)') AS payload_hash,
466+
arrow_cast(column3, 'Float64') AS metric,
467+
arrow_cast(column4, 'Timestamp(ns)') AS ts
468+
FROM (
469+
VALUES
470+
(1, '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', 10.0, 1703030400000000000),
471+
(2, '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', 11.0, 1703031000000000000),
472+
(3, '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', 12.0, 1703031600000000000),
473+
(4, '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', 13.0, 1703032200000000000),
474+
(5, '1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f53', 14.0, 1703032800000000000),
475+
(6, '1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f53', 15.0, 1703033400000000000),
476+
(7, '1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f53', 16.0, 1703034000000000000),
477+
(8, '6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b', 17.0, 1703034600000000000),
478+
(9, '6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b', 18.0, 1703035200000000000),
479+
(10, '6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b', 19.0, 1703035800000000000)
480+
);
481+
482+
statement ok
483+
COPY dict_hash_src
484+
TO 'test_files/scratch/dictionary/dict_hash_10.parquet'
485+
STORED AS PARQUET;
486+
487+
statement ok
488+
CREATE EXTERNAL TABLE dict_hash_10
489+
STORED AS PARQUET
490+
LOCATION 'test_files/scratch/dictionary/dict_hash_10.parquet';
491+
492+
query TTT
493+
DESCRIBE dict_hash_10;
494+
----
495+
id Int64 YES
496+
payload_hash Dictionary(Int32, Utf8) YES
497+
metric Float64 YES
498+
ts Timestamp(ns) YES
499+
500+
query II
501+
SELECT COUNT(*), COUNT(DISTINCT payload_hash)
502+
FROM dict_hash_10;
503+
----
504+
10 3
505+
506+
query I
507+
SELECT COUNT(*)
508+
FROM dict_hash_10
509+
WHERE payload_hash = '1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f53';
510+
----
511+
3
512+
513+
statement ok
514+
DROP TABLE dict_hash_10;
515+
516+
statement ok
517+
DROP TABLE dict_hash_src;

0 commit comments

Comments
 (0)