@@ -122,20 +122,47 @@ function initBatchGetDatas(action: string) {
122
122
123
123
const batchGetDatasBySql = initBatchGetDatas ( "batch_get_datas_by_sql" ) ;
124
124
const batchGetDatasByPayload = initBatchGetDatas ( "batch_get_datas_by_payload" ) ;
125
+ const DEFAULT_LIMIT = 50_000 ;
126
+
127
+ function notifyDataLimit ( ) {
128
+ commonStore . setNotification ( {
129
+ type : "warning" ,
130
+ title : "Data Limit Reached" ,
131
+ message : ( < >
132
+ The current computation has returned more than 50,000 rows of data.
133
+ To ensure optimal performance, we are currently rendering only the first 50,000 rows.
134
+ If you need to render the entire all datas, please use the 'limit' tool
135
+ (< svg className = "inline bg-black" width = "15" height = "15" viewBox = "0 0 15 15" fill = "none" xmlns = "http://www.w3.org/2000/svg" >
136
+ < path
137
+ d = "M9.94969 7.49989C9.94969 8.85288 8.85288 9.94969 7.49989 9.94969C6.14691 9.94969 5.0501 8.85288 5.0501 7.49989C5.0501 6.14691 6.14691 5.0501 7.49989 5.0501C8.85288 5.0501 9.94969 6.14691 9.94969 7.49989ZM10.8632 8C10.6213 9.64055 9.20764 10.8997 7.49989 10.8997C5.79214 10.8997 4.37847 9.64055 4.13662 8H0.5C0.223858 8 0 7.77614 0 7.5C0 7.22386 0.223858 7 0.5 7H4.13659C4.37835 5.35935 5.79206 4.1001 7.49989 4.1001C9.20772 4.1001 10.6214 5.35935 10.8632 7H14.5C14.7761 7 15 7.22386 15 7.5C15 7.77614 14.7761 8 14.5 8H10.8632Z"
138
+ fill = "currentColor"
139
+ fillRule = "evenodd"
140
+ clipRule = "evenodd"
141
+ > </ path >
142
+ </ svg > ) to manually set the maximum number of rows to be returned.
143
+ </ > )
144
+ } , 60_000 ) ;
145
+ }
125
146
126
147
export function getDatasFromKernelBySql ( fieldMetas : any ) {
127
148
return async ( payload : IDataQueryPayload ) => {
128
149
const sql = parser_dsl_with_meta (
129
150
"pygwalker_mid_table" ,
130
- JSON . stringify ( payload ) ,
151
+ JSON . stringify ( { ... payload , limit : payload . limit ?? DEFAULT_LIMIT } ) ,
131
152
JSON . stringify ( { "pygwalker_mid_table" : fieldMetas } )
132
153
) ;
133
- const result = await batchGetDatasBySql . getDatas ( sql ) ;
134
- return ( result ?? [ ] ) as IRow [ ] ;
154
+ const result = await batchGetDatasBySql . getDatas ( sql ) ?? [ ] ;
155
+ if ( ! payload . limit && result . length === DEFAULT_LIMIT ) {
156
+ notifyDataLimit ( ) ;
157
+ }
158
+ return result as IRow [ ] ;
135
159
}
136
160
}
137
161
138
162
export async function getDatasFromKernelByPayload ( payload : IDataQueryPayload ) {
139
- const result = await batchGetDatasByPayload . getDatas ( payload ) ;
140
- return ( result ?? [ ] ) as IRow [ ] ;
163
+ const result = await batchGetDatasByPayload . getDatas ( { ...payload , limit : payload . limit ?? DEFAULT_LIMIT } ) ?? [ ] ;
164
+ if ( ! payload . limit && result . length === DEFAULT_LIMIT ) {
165
+ notifyDataLimit ( ) ;
166
+ }
167
+ return result as IRow [ ] ;
141
168
}
0 commit comments