diff options
author | Michael Armbrust <michael@databricks.com> | 2014-04-19 15:08:54 -0700 |
---|---|---|
committer | Matei Zaharia <matei@databricks.com> | 2014-04-19 15:08:54 -0700 |
commit | 10d04213ffda9c64b7e39c7debc433be8ea343c7 (patch) | |
tree | 7a10ed2f34c6860ba21d375f969ddadb477c9069 /python | |
parent | 5d0f58b2eb8e48a95c4ab34bc89f7251d093f301 (diff) | |
download | spark-10d04213ffda9c64b7e39c7debc433be8ea343c7.tar.gz spark-10d04213ffda9c64b7e39c7debc433be8ea343c7.tar.bz2 spark-10d04213ffda9c64b7e39c7debc433be8ea343c7.zip |
Add insertInto and saveAsTable to Python API.
Author: Michael Armbrust <michael@databricks.com>
Closes #447 from marmbrus/pythonInsert and squashes the following commits:
c7ab692 [Michael Armbrust] Keep docstrings < 72 chars.
ff62870 [Michael Armbrust] Add insertInto and saveAsTable to Python API.
Diffstat (limited to 'python')
-rw-r--r-- | python/pyspark/sql.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/python/pyspark/sql.py b/python/pyspark/sql.py index 27753d5ba5..114fa138d0 100644 --- a/python/pyspark/sql.py +++ b/python/pyspark/sql.py @@ -305,6 +305,19 @@ class SchemaRDD(RDD): """ self._jschema_rdd.registerAsTable(name) + def insertInto(self, tableName, overwrite = False): + """ + Inserts the contents of this SchemaRDD into the specified table, + optionally overwriting any existing data. + """ + self._jschema_rdd.insertInto(tableName, overwrite) + + def saveAsTable(self, tableName): + """ + Creates a new table with the contents of this SchemaRDD. + """ + self._jschema_rdd.saveAsTable(tableName) + def _toPython(self): # We have to import the Row class explicitly, so that the reference Pickler has is # pyspark.sql.Row instead of __main__.Row |