@@ -2493,8 +2493,7 @@ def from_spark(df, key=[]):
2493
2493
:class:`.Table`
2494
2494
Table constructed from the Spark SQL DataFrame.
2495
2495
"""
2496
-
2497
- return Table ._from_java (Env .hail ().table .Table .fromDF (Env .hc ()._jhc , df ._jdf , key ))
2496
+ return Env .spark_backend ('from_spark' ).from_spark (df , key )
2498
2497
2499
2498
@typecheck_method (flatten = bool )
2500
2499
def to_spark (self , flatten = True ):
@@ -2513,10 +2512,7 @@ def to_spark(self, flatten=True):
2513
2512
:class:`.pyspark.sql.DataFrame`
2514
2513
2515
2514
"""
2516
- t = self .expand_types ()
2517
- if flatten :
2518
- t = t .flatten ()
2519
- return pyspark .sql .DataFrame (t ._jt .toDF (Env .hc ()._jsql_context ), Env .sql_context ())
2515
+ return Env .spark_backend ('to_spark' ).to_spark (self , flatten )
2520
2516
2521
2517
@typecheck_method (flatten = bool )
2522
2518
def to_pandas (self , flatten = True ):
@@ -2536,7 +2532,7 @@ def to_pandas(self, flatten=True):
2536
2532
:class:`.pandas.DataFrame`
2537
2533
2538
2534
"""
2539
- return self . to_spark ( flatten ). toPandas ( )
2535
+ return Env . spark_backend ( 'to_pandas' ). to_pandas ( self , flatten )
2540
2536
2541
2537
@staticmethod
2542
2538
@typecheck (df = pandas .DataFrame ,
@@ -2560,7 +2556,7 @@ def from_pandas(df, key=[]):
2560
2556
-------
2561
2557
:class:`.Table`
2562
2558
"""
2563
- return Table . from_spark ( Env .sql_context (). createDataFrame (df ) , key )
2559
+ return Env .spark_backend ( 'from_pandas' ). from_pandas (df , key )
2564
2560
2565
2561
@typecheck_method (other = table_type , tolerance = nullable (numeric ), absolute = bool )
2566
2562
def _same (self , other , tolerance = 1e-6 , absolute = False ):
0 commit comments