Repository: databricks/koalas

Issue:
clean up all the printing statements
They should either be removed or transformed as logging


Discussion:

Resolving patch:
diff --git a/databricks/koala/structures.py b/databricks/koala/structures.py
--- a/databricks/koala/structures.py
+++ b/databricks/koala/structures.py
@@ -276,17 +276,11 @@ def _pandas_anchor(self) -> DataFrame:
         n = self._pandas_orig_repr()
         raise ValueError("No reference to a dataframe for column {}".format(n))
 
-    # DANGER: will materialize.
-    def __iter__(self):
-        print("__iter__", self)
-        return self.toPandas().__iter__()
-
     def __len__(self):
         return len(self.to_dataframe())
 
     def __getitem__(self, key):
         res = anchor_wrap(self, self._spark_getitem(key))
-        print("series:getitem:", key, self.schema, res)
         return res
 
     def __getattr__(self, item):
@@ -595,7 +589,6 @@ def shape(self):
         return len(self), len(self.columns)
 
     def _pd_getitem(self, key):
-        # print("__getitem__:key", key, type(key))
         if key is None:
             raise KeyError("none key")
         if isinstance(key, string_types):
@@ -650,7 +643,6 @@ def __getattr__(self, key):
         return anchor_wrap(self, self._spark_getattr(key))
 
     def __iter__(self):
-        print("df__iter__", self)
         return self.toPandas().__iter__()
 
     def __len__(self):
diff --git a/databricks/koala/typing.py b/databricks/koala/typing.py
--- a/databricks/koala/typing.py
+++ b/databricks/koala/typing.py
@@ -157,9 +157,6 @@ def make_fun(f, *args, **kwargs):
         else:
             frozen_args.append(arg2)
         final_args.append(arg2)
-    print("final_args", final_args)
-    print("col_indexs", col_indexes)
-    print("frozen_args", frozen_args)
     sig_kwargs = f.sig_kwargs  # type: typing.Dict[str, X]
     final_kwargs = {}
     col_keys = []
@@ -173,7 +170,6 @@ def make_fun(f, *args, **kwargs):
             frozen_kwargs[key] = None
         else:
             frozen_kwargs[key] = arg2
-    print("col_keys", col_keys)
     if not col_keys and not col_indexes:
         # No argument is related to spark
         # The function is just called through without other considerations.
@@ -188,15 +184,12 @@ def make_fun(f, *args, **kwargs):
     # We build a new UDF that only takes arguments from columns, the rest is
     # sent inside the closure into the function.
     all_indexes = col_indexes + col_keys  # type: typing.Union[str, int]
-    print("all_indexes", all_indexes)
 
     def clean_fun(*args2):
         assert len(args2) == len(all_indexes),\
             "Missing some inputs:{}!={}".format(all_indexes, [str(c) for c in args2])
         full_args = list(frozen_args)
         full_kwargs = dict(frozen_kwargs)
-        print("full_kwargs", full_kwargs)
-        print("full_args", full_args)
         for (arg, idx) in zip(args2, all_indexes):
             if isinstance(idx, int):
                 full_args[idx] = arg
@@ -221,14 +214,12 @@ def _wrap_callable(obj):
     f0 = obj.__call__
 
     def f(*args, **kwargs):
-        print("xxxx")
         return f0(*args, **kwargs)
     obj.__call__ = f
     return obj
 
 
 def pandas_wrap(f, return_col=None):
-    print("pandas_wrap:f=", f)
     # Extract the signature arguments from this function.
     spec = getfullargspec(f)
     rtype = None
@@ -256,7 +247,4 @@ def pandas_wrap(f, return_col=None):
     f.sig_return = rtype
     f.sig_args = sig_args
     f.sig_kwargs = sig_kwargs
-    print("sig_return", rtype)
-    print("sig_args", sig_args)
-    print("sig_kwargs", sig_kwargs)
     return decorate(f, make_fun)
diff --git a/databricks/koala/utils.py b/databricks/koala/utils.py
--- a/databricks/koala/utils.py
+++ b/databricks/koala/utils.py
@@ -66,10 +66,8 @@ def patch_spark():
 @decorator
 def wrap_column_function(f, *args, **kwargs):
     # Call the function first
-    # print("wrap_column_function:calling {} on args={}, kwargs={}".format(f, args, kwargs))
     res = f(*args, **kwargs)
     if isinstance(res, col.Column):
-        # print("res is a column")
         # Need to track where this column is coming from
         all_inputs = list(args) + list(kwargs.values())
 
@@ -80,12 +78,10 @@ def ref_df(x):
                 if hasattr(x, "_spark_ref_dataframe"):
                     return x._spark_ref_dataframe
                 else:
-                    logger.warning("Found a column without reference: {}".format(str(x)))
+                    logger.debug("Found a column without reference: {}".format(str(x)))
             return None
         all_col_inputs = [ref_df(c) for c in all_inputs]
-        # print("wrap_column_function:all_col_inputs", all_col_inputs)
         all_df_inputs = list(dict([(id(f), f) for f in all_col_inputs if f]).items())
-        # print("wrap_column_function:all_df_inputs", all_df_inputs)
         if len(all_df_inputs) > 1:
             logger.warning("Too many anchors to conclude")
         elif not all_df_inputs:
@@ -127,7 +123,6 @@ def _inject(target_type, inject_type):
     # Make sure to resolve the base classes too.
     mro = list(inject_type.__mro__)
     mro.reverse()
-    print(mro)
     # Keep a duplicate of all the existing methods:
     setattr(target_type, "_spark_getattr", target_type.__getattr__)
     setattr(target_type, "_spark_getitem", target_type.__getitem__)


Test patch: