-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'branch-24.08' into pylibcudf-strings-slice
- Loading branch information
Showing
12 changed files
with
329 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "large_strings_fixture.hpp" | ||
|
||
#include <cudf/io/json.hpp> | ||
#include <cudf/utilities/span.hpp> | ||
|
||
struct JsonLargeReaderTest : public cudf::test::StringsLargeTest {}; | ||
|
||
TEST_F(JsonLargeReaderTest, MultiBatch) | ||
{ | ||
std::string json_string = R"( | ||
{ "a": { "y" : 6}, "b" : [1, 2, 3], "c": 11 } | ||
{ "a": { "y" : 6}, "b" : [4, 5 ], "c": 12 } | ||
{ "a": { "y" : 6}, "b" : [6 ], "c": 13 } | ||
{ "a": { "y" : 6}, "b" : [7 ], "c": 14 })"; | ||
constexpr size_t expected_file_size = std::numeric_limits<int>::max() / 2; | ||
std::size_t const log_repetitions = | ||
static_cast<std::size_t>(std::ceil(std::log2(expected_file_size / json_string.size()))); | ||
|
||
json_string.reserve(json_string.size() * (1UL << log_repetitions)); | ||
std::size_t numrows = 4; | ||
for (std::size_t i = 0; i < log_repetitions; i++) { | ||
json_string += json_string; | ||
numrows <<= 1; | ||
} | ||
|
||
constexpr int num_sources = 2; | ||
std::vector<cudf::host_span<char>> hostbufs( | ||
num_sources, cudf::host_span<char>(json_string.data(), json_string.size())); | ||
|
||
// Initialize parsing options (reading json lines) | ||
cudf::io::json_reader_options json_lines_options = | ||
cudf::io::json_reader_options::builder( | ||
cudf::io::source_info{ | ||
cudf::host_span<cudf::host_span<char>>(hostbufs.data(), hostbufs.size())}) | ||
.lines(true) | ||
.compression(cudf::io::compression_type::NONE) | ||
.recovery_mode(cudf::io::json_recovery_mode_t::FAIL); | ||
|
||
// Read full test data via existing, nested JSON lines reader | ||
cudf::io::table_with_metadata current_reader_table = cudf::io::read_json(json_lines_options); | ||
ASSERT_EQ(current_reader_table.tbl->num_rows(), numrows * num_sources); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
import polars as pl | ||
|
||
from cudf_polars.testing.asserts import assert_gpu_result_equal | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"subset", | ||
[ | ||
None, | ||
["a", "c"], | ||
["b", "c", "d"], | ||
["b", "d"], | ||
["b", "c"], | ||
["c", "e"], | ||
["d", "e"], | ||
pl.selectors.string(), | ||
pl.selectors.integer(), | ||
], | ||
) | ||
@pytest.mark.parametrize("predicate_pushdown", [False, True]) | ||
def test_scan_drop_nulls(subset, predicate_pushdown): | ||
df = pl.LazyFrame( | ||
{ | ||
"a": [1, 2, 3, 4], | ||
"b": [None, 4, 5, None], | ||
"c": [6, 7, None, None], | ||
"d": [8, None, 9, 10], | ||
"e": [None, None, "A", None], | ||
} | ||
) | ||
# Drop nulls are pushed into filters | ||
q = df.drop_nulls(subset) | ||
|
||
assert_gpu_result_equal( | ||
q, collect_kwargs={"predicate_pushdown": predicate_pushdown} | ||
) |
Oops, something went wrong.