Skip to content

Commit 93de83a

Browse files
author
Matt Severini
committed
only apply the limit when specified
1 parent a773929 commit 93de83a

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

config.json.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"port": 5432
2020
},
2121
"keep_disconnected_tables": false,
22-
"max_rows_per_table": ALL,
2322
"excluded_tables": [ ],
2423
"passthrough_tables": [ ],
2524
"dependency_breaks": [ ],

config_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def get_post_subset_sql():
6060
return _config["post_subset_sql"] if "post_subset_sql" in _config else []
6161

6262
def get_max_rows_per_table():
63-
return _config["max_rows_per_table"]
63+
return _config["max_rows_per_table"] if "max_rows_per_table" in _config else None
6464

6565
def __convert_tonic_format(obj):
6666
if "fk_schema" in obj:

subset.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ def run_middle_out(self):
7171
start_time = time.time()
7272
for idx, t in enumerate(passthrough_tables):
7373
print_progress(t, idx+1, len(passthrough_tables))
74-
q = 'SELECT * FROM {} LIMIT {}'.format(fully_qualified_table(t), config_reader.get_max_rows_per_table())
74+
q = 'SELECT * FROM {}'.format(fully_qualified_table(t))
75+
if config_reader.get_max_rows_per_table() is not None:
76+
q += 'LIMIT {}'.format(config_reader.get_max_rows_per_table())
7577
self.__db_helper.copy_rows(self.__source_conn, self.__destination_conn, q, mysql_db_name_hack(t, self.__destination_conn))
7678
print('Pass-through completed in {}s'.format(time.time()-start_time))
7779

@@ -140,7 +142,8 @@ def __subset_upstream(self, target, processed_tables, relationships):
140142
clauses.extend(upstream_filter_match(target, table_columns))
141143

142144
select_query = 'SELECT * FROM {} WHERE TRUE AND {}'.format(quoter(temp_target_name), ' AND '.join(clauses))
143-
select_query += " LIMIT {}".format(config_reader.get_max_rows_per_table())
145+
if config_reader.get_max_rows_per_table() is not None:
146+
select_query += " LIMIT {}".format(config_reader.get_max_rows_per_table())
144147
insert_query = 'INSERT INTO {} {}'.format(fully_qualified_table(mysql_db_name_hack(target, self.__destination_conn)), select_query)
145148
self.__db_helper.run_query(insert_query, self.__destination_conn)
146149
self.__destination_conn.commit()

0 commit comments

Comments
 (0)