Skip to content

Commit

Permalink
Revert "Setting max_size to a hard_limit if failed once (#297)"
Browse files Browse the repository at this point in the history
This reverts commit 6ef7811.
  • Loading branch information
cjohns-scottlogic authored Dec 4, 2024
1 parent 6ef7811 commit 3ddbfe8
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions digital_land/package/datasetparquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
import duckdb
from .package import Package
import resource

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -65,15 +64,15 @@ def create_temp_table(self, input_paths):

input_paths_str = ", ".join([f"'{path}'" for path in input_paths])

self.conn.execute("DROP TABLE IF EXISTS temp_table")
# Initial max_line_size and increment step
max_size = 40000000
# increment_step = 20000000
increment_step = 20000000
# max_limit = 200000000 # Maximum allowable line size to attempt

# increment = False
increment = False
while True:
try:
self.conn.execute("DROP TABLE IF EXISTS temp_table")
query = f"""
CREATE TEMPORARY TABLE temp_table AS
SELECT *
Expand All @@ -86,19 +85,14 @@ def create_temp_table(self, input_paths):
)
"""
self.conn.execute(query)
if increment:
logging.info(f"Ended up needing a value of max_size = {max_size}")
break
except duckdb.Error as e: # Catch specific DuckDB error
if "Value with unterminated quote" in str(e):
hard_limit = int(resource.getrlimit(resource.RLIMIT_AS)[1])
if max_size < hard_limit / 3:
logging.info(
f"Initial max_size did not work, setting it to {hard_limit / 2}"
)
max_size = hard_limit / 2
else:
raise
increment = True
max_size += increment_step
else:
logging.info(f"Failed to read in when max_size = {max_size}")
raise

def load_facts(self):
Expand Down

0 comments on commit 3ddbfe8

Please sign in to comment.