Repository: spark Updated Branches: refs/heads/master 5d0f58b2e -> 10d04213f
Add insertInto and saveAsTable to Python API. Author: Michael Armbrust <[email protected]> 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. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/10d04213 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/10d04213 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/10d04213 Branch: refs/heads/master Commit: 10d04213ffda9c64b7e39c7debc433be8ea343c7 Parents: 5d0f58b Author: Michael Armbrust <[email protected]> Authored: Sat Apr 19 15:08:54 2014 -0700 Committer: Matei Zaharia <[email protected]> Committed: Sat Apr 19 15:08:54 2014 -0700 ---------------------------------------------------------------------- python/pyspark/sql.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/10d04213/python/pyspark/sql.py ---------------------------------------------------------------------- diff --git a/python/pyspark/sql.py b/python/pyspark/sql.py index 27753d5..114fa13 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
