andy-clapson commented on issue #37612:
URL: https://github.com/apache/superset/issues/37612#issuecomment-3836191939

   > You're correct about the root cause of the data preview issue: the 
`runTablePreviewQuery` function does not set `queryLimit` in the 
`dataPreviewQuery` object, so the backend defaults to `SQL_MAX_ROW` (typically 
100,000), resulting in unnecessarily large queries for previews. To fix this, 
add `queryLimit: PREVIEW_QUERY_LIMIT` (or just `100`) to the `dataPreviewQuery` 
object in `runTablePreviewQuery` so the backend enforces the intended row limit 
for previews. This will prevent the backend from fetching excessive rows and 
improve performance for large tables. [See supporting 
code](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/SqlLab/actions/sqlLab.js#L66-L1015)
 | [PREVIEW_QUERY_LIMIT 
usage](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/SqlLab/components/TablePreview/index.tsx#L90-L242)
 | [Backend limit 
logic](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b
 1ed3b063ffe45377799c/superset/sqllab/sqllab_execution_context.py#L64-L183).
   > 
   > For the second issue, the float vs. decimal TypeError in the results error 
handler has already been resolved in the current codebase. The problematic 
subtraction between `now_as_float()` and `self._query.end_time` no longer 
exists, so you shouldn't encounter this error on the latest master branch. [See 
results handler 
code](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/commands/sql_lab/results.py#L31-L131).
   > 
   > _To reply, just mention [@dosu](https://go.dosu.dev/dosubot)._
   > 
   > How did I do? 
[Good](https://app.dosu.dev/response-feedback/07f9b20c-e9a4-43db-9083-66fac9ecb86e?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/07f9b20c-e9a4-43db-9083-66fac9ecb86e?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/07f9b20c-e9a4-43db-9083-66fac9ecb86e?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/07f9b20c-e9a4-43db-9083-66fac9ecb86e?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/07f9b20c-e9a4-43db-9083-66fac9ecb86e?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/07f9b20c-e9a4-43db-9083-66fac9ecb86e?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/07f9b20c-e9a4-43db-9083-66fac9ecb86e?feedback_type=other)
   > 
   > [![Chat with 
Dosu](https://camo.githubusercontent.com/7c571478962a6b8a5d47cac74b6824c75e4f6731bba52377e6007f9150462923/68747470733a2f2f646f73752e6465762f646f73752d636861742d62616467652e737667)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)
 [![Open in 
Cursor](https://camo.githubusercontent.com/bdf7dbded65ee585887f47e5fd6fa099ea0933088b4b03d02e83b4def50154d4/68747470733a2f2f646f73752e6465762f646f73752d696e2d637572736f722e737667)](https://cursor.com/link/prompt?text=You%27re%20correct%20about%20the%20root%20cause%20of%20the%20data%20preview%20issue%3A%20the%20%60runTablePreviewQuery%60%20function%20does%20not%20set%20%60queryLimit%60%20in%20the%20%60dataPreviewQuery%60%20object%2C%20so%20the%20backend%20defaults%20to%20%60SQL_MAX_ROW%60%20%28typically%20100%2C000%29%2C%20resulting%20in%20unnecessarily%20large%20queries%20for%20previews.%20To%20fix%20this%2C%20add%20%60queryLimit%3A%20PREVIEW_QUERY_LIMIT%60%20%28or%20just%20%60100%60%29%20to%20the%
 
20%60dataPreviewQuery%60%20object%20in%20%60runTablePreviewQuery%60%20so%20the%20backend%20enforces%20the%20intended%20row%20limit%20for%20previews.%20This%20will%20prevent%20the%20backend%20from%20fetching%20excessive%20rows%20and%20improve%20performance%20for%20large%20tables.%20%20%0A%5BSee%20supporting%20code%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/SqlLab/actions/sqlLab.js%23L66-L1015%29%20%7C%20%5BPREVIEW_QUERY_LIMIT%20usage%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/SqlLab/components/TablePreview/index.tsx%23L90-L242%29%20%7C%20%5BBackend%20limit%20logic%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/sqllab/sqllab_execution_context.py%23L64-L183%29.%0A%0AFor%20the%20second%20issue%2C%20the%20float%20vs.%20decimal%20TypeError%20in%20the%20results%20error%20handler%20has%20already%20been%20resol
 
ved%20in%20the%20current%20codebase.%20The%20problematic%20subtraction%20between%20%60now_as_float%28%29%60%20and%20%60self._query.end_time%60%20no%20longer%20exists%2C%20so%20you%20shouldn%27t%20encounter%20this%20error%20on%20the%20latest%20master%20branch.%20%20%0A%5BSee%20results%20handler%20code%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/commands/sql_lab/results.py%23L31-L131%29.)
 [![Join 
Discord](https://camo.githubusercontent.com/7d2066700925db1e370d956834f9ea0e5bc92cecbe84963fbd2a363e45091b4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d3538363546323f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465266c6162656c3d)](https://go.dosu.dev/discord-bot)
 [![Share on 
X](https://camo.githubusercontent.com/a8bd7f3fcf3f5e3bd124eee9ae50ae2ac17b40971726665ac2121d48f9aee155/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d73686172652d626c61636b)](https://twitter.com/intent/tweet?text=%40dosu_a
 
i%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/37612)
   
   I'm not sure about your 2nd point here...I think I still see it there...?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to