-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SEDONA-663] Support spark connect python api (#1639)
* initial successful test * try add docker-compose based tests * 3.5 only * comment classic tests * try fix yaml * skip other workflows * skip other workflows * try fix if check * fix path * cd to python folder * skip sparkContext with SPARK_REMOTE * fix type check * refactor somewhat * Revert "skip other workflows" This reverts commit 7eb9b6e * back to full matrix * add license header, fix missing whitespace * Add a simple docstring to SedonaFunction * uncomment build step * need sql extensions * run pre-commit * fix lint/pre-commit * Update .github/workflows/python.yml Co-authored-by: John Bampton <[email protected]> * adjust spelling * use UnresolvedFunction instead of CallFunction * revert Pipfile to master rev --------- Co-authored-by: John Bampton <[email protected]>
- Loading branch information
Showing
5 changed files
with
123 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
|
||
from typing import Any, Iterable, List | ||
|
||
import pyspark.sql.connect.functions as f | ||
from pyspark.sql.connect.column import Column | ||
from pyspark.sql.connect.expressions import UnresolvedFunction | ||
|
||
|
||
# mimic semantics of _convert_argument_to_java_column | ||
def _convert_argument_to_connect_column(arg: Any) -> Column: | ||
if isinstance(arg, Column): | ||
return arg | ||
elif isinstance(arg, str): | ||
return f.col(arg) | ||
elif isinstance(arg, Iterable): | ||
return f.array(*[_convert_argument_to_connect_column(x) for x in arg]) | ||
else: | ||
return f.lit(arg) | ||
|
||
|
||
def call_sedona_function_connect(function_name: str, args: List[Any]) -> Column: | ||
|
||
expressions = [_convert_argument_to_connect_column(arg)._expr for arg in args] | ||
return Column(UnresolvedFunction(function_name, expressions)) |
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