From 10d04213ffda9c64b7e39c7debc433be8ea343c7 Mon Sep 17 00:00:00 2001
From: Michael Armbrust <michael@databricks.com>
Date: Sat, 19 Apr 2014 15:08:54 -0700
Subject: [PATCH] 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.
---
 python/pyspark/sql.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

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
-- 
GitLab