From 2d2218c6933ba7c5264a602df2ff149643ce86ce Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Tue, 20 Jun 2017 14:37:14 -0400 Subject: [PATCH] update constant to avoid overview generation --- cartoframes/context.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cartoframes/context.py b/cartoframes/context.py index a3ead2163..38f97baf5 100644 --- a/cartoframes/context.py +++ b/cartoframes/context.py @@ -33,7 +33,9 @@ from urlparse import urlparse from urllib import urlencode -MAX_IMPORT_ROWS = 500000 +# Choose constant to avoid overview generation which are triggered at a +# half million rows +MAX_IMPORT_ROWS = 499999 class CartoContext(object): """Manages connections with CARTO for data and map operations. Modeled @@ -222,7 +224,7 @@ def _send_batches(self, df, table_name, temp_dir, geom_col): # send dataframe chunks to carto for chunk_num, chunk in tqdm(df.groupby([i // MAX_IMPORT_ROWS for i in range(df.shape[0])]), - desc='Uploading'): + desc='Uploading in batches: '): temp_table = '{orig}_cartoframes_temp_{chunk}'.format( orig=table_name[:40], chunk=chunk_num) @@ -246,7 +248,6 @@ def _send_batches(self, df, table_name, temp_dir, geom_col): 'FROM "{table}"') % dict(schema=df2pg_schema(df)) unioned_tables = '\nUNION ALL\n'.join([select_base.format(table=t) for t in subtables]) - print(unioned_tables) self._debug_print(unioned=unioned_tables) query = ''' DROP TABLE IF EXISTS "{table_name}"; @@ -1039,7 +1040,7 @@ def df2pg_schema(dataframe): if c not in ('the_geom', 'the_geom_webmercator', 'cartodb_id')]) if 'the_geom' in dataframe.columns: - return 'the_geom, ' + schema + return '"the_geom", ' + schema return schema def _drop_tables_query(tables):