dosubot[bot] commented on issue #37612:
URL: https://github.com/apache/superset/issues/37612#issuecomment-3835742509

   <!-- Answer -->
   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/829e4d92d91ceae4b43b1ed3b063ffe45377799c/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).
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>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)</sup>
   
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](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%20larg
 
e%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%20resolved%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.)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/37612)


-- 
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