-
Notifications
You must be signed in to change notification settings - Fork 928
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves [10219](NVIDIA/spark-rapids#10219) This PR introduces a new class named `GetJsonObjectOptions` that holds the configurations to control the behavior of the underlying `cudf::get_json_object` function. It incorporates this new class into the `getJSONObject` JAVA API as an additional argument but also keeps the previous API to maintain backwards compatibility. It also includes a test case, `testGetJSONObjectWithSingleQuotes`, validating the behavior of `getJSONObject` when single quotes are enabled. Authors: - Suraj Aralihalli (https://github.com/SurajAralihalli) Approvers: - Robert (Bobby) Evans (https://github.com/revans2) - MithunR (https://github.com/mythrocks) - Karthikeyan (https://github.com/karthikeyann) URL: #14956
1 parent
daa63d2
commit 49c2995
Showing
4 changed files
with
119 additions
and
6 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
75 changes: 75 additions & 0 deletions
75
java/src/main/java/ai/rapids/cudf/GetJsonObjectOptions.java
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,75 @@ | ||
/* | ||
* | ||
* 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. | ||
* | ||
*/ | ||
|
||
package ai.rapids.cudf; | ||
|
||
public final class GetJsonObjectOptions { | ||
|
||
public static GetJsonObjectOptions DEFAULT = new GetJsonObjectOptions.Builder().build(); | ||
|
||
private final boolean allowSingleQuotes; | ||
private final boolean stripQuotesFromSingleStrings; | ||
private final boolean missingFieldsAsNulls; | ||
|
||
private GetJsonObjectOptions(Builder builder) { | ||
this.allowSingleQuotes = builder.allowSingleQuotes; | ||
this.stripQuotesFromSingleStrings = builder.stripQuotesFromSingleStrings; | ||
this.missingFieldsAsNulls = builder.missingFieldsAsNulls; | ||
} | ||
|
||
public boolean isAllowSingleQuotes() { | ||
return allowSingleQuotes; | ||
} | ||
|
||
public boolean isStripQuotesFromSingleStrings() { | ||
return stripQuotesFromSingleStrings; | ||
} | ||
|
||
public boolean isMissingFieldsAsNulls() { | ||
return missingFieldsAsNulls; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static final class Builder { | ||
private boolean allowSingleQuotes = false; | ||
private boolean stripQuotesFromSingleStrings = true; | ||
private boolean missingFieldsAsNulls = false; | ||
|
||
public Builder allowSingleQuotes(boolean allowSingleQuotes) { | ||
this.allowSingleQuotes = allowSingleQuotes; | ||
return this; | ||
} | ||
|
||
public Builder stripQuotesFromSingleStrings(boolean stripQuotesFromSingleStrings) { | ||
this.stripQuotesFromSingleStrings = stripQuotesFromSingleStrings; | ||
return this; | ||
} | ||
|
||
public Builder missingFieldsAsNulls(boolean missingFieldsAsNulls) { | ||
this.missingFieldsAsNulls = missingFieldsAsNulls; | ||
return this; | ||
} | ||
|
||
public GetJsonObjectOptions build() { | ||
return new GetJsonObjectOptions(this); | ||
} | ||
} | ||
} |
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