@@ -1866,3 +1866,58 @@ def generate_column_prefix_groupings(
18661866 )
18671867
18681868 return list (zip (margin_data_column_prefixes , margin_data_column_groupings ))
1869+
1870+
1871+ def check_pivot_table_unsupported_args (args : dict ) -> Optional [str ]:
1872+ """
1873+ Validate pivot_table arguments for unsupported conditions.
1874+
1875+ This helper function checks various argument combinations that are not yet
1876+ supported by Snowpark pandas pivot_table implementation.
1877+
1878+ Args:
1879+ args : dictionary of arguments passed to pivot_table
1880+
1881+ Returns:
1882+ Error message if an unsupported condition is found, None otherwise
1883+ """
1884+ # Check if index argument is a string or list of strings
1885+ index = args .get ("index" )
1886+ if (
1887+ index is not None
1888+ and not isinstance (index , str )
1889+ and not all (isinstance (v , str ) for v in index )
1890+ and None not in index
1891+ ):
1892+ return "index argument should be a string or a list of strings"
1893+
1894+ # Check if columns argument is a string or list of strings
1895+ columns = args .get ("columns" )
1896+ if (
1897+ columns is not None
1898+ and not isinstance (columns , str )
1899+ and not all (isinstance (v , str ) for v in columns )
1900+ and None not in columns
1901+ ):
1902+ return "columns argument should be a string or a list of strings"
1903+
1904+ # Check if values argument is a string or list of strings
1905+ values = args .get ("values" )
1906+ if (
1907+ values is not None
1908+ and not isinstance (values , str )
1909+ and not all (isinstance (v , str ) for v in values )
1910+ and None not in values
1911+ ):
1912+ return "values argument should be a string or a list of strings"
1913+
1914+ # Check for dictionary aggfunc with non-string functions when index is None
1915+ aggfunc = args .get ("aggfunc" )
1916+ if (
1917+ isinstance (aggfunc , dict )
1918+ and any (not isinstance (af , str ) for af in aggfunc .values ())
1919+ and args .get ("index" ) is None
1920+ ):
1921+ return "dictionary aggfunc with non-string aggregation functions is not yet supported for pivot_table when index is None"
1922+
1923+ return None
0 commit comments