Skip to content

Commit 4e46852

Browse files
itholicHyukjinKwon
authored andcommitted
[SPARK-47827][PYTHON] Missing warnings for deprecated features
### What changes were proposed in this pull request? This PR proposes to add missing warnings for deprecated features ### Why are the changes needed? Some APIs will be removed so we should provide proper warnings when users try using it ### Does this PR introduce _any_ user-facing change? No API changes, but the deprecated APIs now shows proper warnings ### How was this patch tested? The existing CI should pass. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#46021 from itholic/SPARK-47827. Authored-by: Haejoon Lee <haejoon.lee@databricks.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
1 parent 1ee3496 commit 4e46852

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

python/pyspark/sql/connect/catalog.py

+18
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ def listFunctions(
166166
listFunctions.__doc__ = PySparkCatalog.listFunctions.__doc__
167167

168168
def functionExists(self, functionName: str, dbName: Optional[str] = None) -> bool:
169+
if dbName is not None:
170+
warnings.warn(
171+
"`dbName` has been deprecated since Spark 3.4 and might be removed in "
172+
"a future version. Use functionExists(`dbName.tableName`) instead.",
173+
FutureWarning,
174+
)
169175
table = self._execute_and_fetch(
170176
plan.FunctionExists(function_name=functionName, db_name=dbName)
171177
)
@@ -187,6 +193,12 @@ def getFunction(self, functionName: str) -> Function:
187193
getFunction.__doc__ = PySparkCatalog.getFunction.__doc__
188194

189195
def listColumns(self, tableName: str, dbName: Optional[str] = None) -> List[Column]:
196+
if dbName is not None:
197+
warnings.warn(
198+
"`dbName` has been deprecated since Spark 3.4 and might be removed in "
199+
"a future version. Use listColumns(`dbName.tableName`) instead.",
200+
FutureWarning,
201+
)
190202
table = self._execute_and_fetch(plan.ListColumns(table_name=tableName, db_name=dbName))
191203
return [
192204
Column(
@@ -203,6 +215,12 @@ def listColumns(self, tableName: str, dbName: Optional[str] = None) -> List[Colu
203215
listColumns.__doc__ = PySparkCatalog.listColumns.__doc__
204216

205217
def tableExists(self, tableName: str, dbName: Optional[str] = None) -> bool:
218+
if dbName is not None:
219+
warnings.warn(
220+
"`dbName` has been deprecated since Spark 3.4 and might be removed in "
221+
"a future version. Use tableExists(`dbName.tableName`) instead.",
222+
FutureWarning,
223+
)
206224
table = self._execute_and_fetch(plan.TableExists(table_name=tableName, db_name=dbName))
207225
return table[0][0].as_py()
208226

python/pyspark/sql/connect/functions/builtin.py

+5
Original file line numberDiff line numberDiff line change
@@ -3467,6 +3467,7 @@ def to_timestamp_ntz(
34673467

34683468

34693469
def bucket(numBuckets: Union[Column, int], col: "ColumnOrName") -> Column:
3470+
warnings.warn("Deprecated in 4.0.0, use partitioning.bucket instead.", FutureWarning)
34703471
from pyspark.sql.connect.functions import partitioning
34713472

34723473
return partitioning.bucket(numBuckets, col)
@@ -3476,6 +3477,7 @@ def bucket(numBuckets: Union[Column, int], col: "ColumnOrName") -> Column:
34763477

34773478

34783479
def years(col: "ColumnOrName") -> Column:
3480+
warnings.warn("Deprecated in 4.0.0, use partitioning.years instead.", FutureWarning)
34793481
from pyspark.sql.connect.functions import partitioning
34803482

34813483
return partitioning.years(col)
@@ -3485,6 +3487,7 @@ def years(col: "ColumnOrName") -> Column:
34853487

34863488

34873489
def months(col: "ColumnOrName") -> Column:
3490+
warnings.warn("Deprecated in 4.0.0, use partitioning.months instead.", FutureWarning)
34883491
from pyspark.sql.connect.functions import partitioning
34893492

34903493
return partitioning.months(col)
@@ -3494,6 +3497,7 @@ def months(col: "ColumnOrName") -> Column:
34943497

34953498

34963499
def days(col: "ColumnOrName") -> Column:
3500+
warnings.warn("Deprecated in 4.0.0, use partitioning.days instead.", FutureWarning)
34973501
from pyspark.sql.connect.functions import partitioning
34983502

34993503
return partitioning.days(col)
@@ -3503,6 +3507,7 @@ def days(col: "ColumnOrName") -> Column:
35033507

35043508

35053509
def hours(col: "ColumnOrName") -> Column:
3510+
warnings.warn("Deprecated in 4.0.0, use partitioning.hours instead.", FutureWarning)
35063511
from pyspark.sql.connect.functions import partitioning
35073512

35083513
return partitioning.hours(col)

0 commit comments

Comments
 (0)