Untitled
unknown
plain_text
2 years ago
961 B
4
Indexable
@validator("sql") def validate_sql(cls, sql): if len(sql) < 1: raise HTTPException(status_code=400, detail="At least one SQL query must be provided") for query in sql: if not re.match(r"^SELECT", query, re.IGNORECASE): raise HTTPException(status_code=400, detail="SQL query must start with 'SELECT'") return sql @validator("data_file") def validate_data_file(cls, data_file): if not data_file.endswith(".parquet"): #raise ValueError("Data file must have a .parquet extension") raise HTTPException(status_code=400, detail="Invalid Parquet file") try: client = S3_funcs.s3Setup() client.head_object(Bucket='your-bucket-name', Key=data_file) except ClientError as e: raise HTTPException(status_code=400, detail="The {file_data} is not found on the S3 bucket") return data_file
Editor is loading...