forked from Kanaries/pygwalker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add use duckdb to compute datas
- Loading branch information
1 parent
4c9dff0
commit fc80561
Showing
20 changed files
with
726 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ def to_html( | |
False, | ||
False, | ||
False, | ||
False, | ||
**kwargs | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import List, Dict, Any | ||
|
||
import duckdb | ||
|
||
from pygwalker._typing import DataFrame | ||
|
||
|
||
def get_datas_from_dataframe(df: DataFrame, sql: str) -> List[Dict[str, Any]]: | ||
""" | ||
Get datas from dataframe by sql(duckdb). | ||
""" | ||
mid_table_name = "__mid_df" | ||
sql = sql.encode('utf-8').decode('unicode_escape') | ||
result = duckdb.query_df(df, mid_table_name, sql) | ||
return [ | ||
dict(zip(result.columns, row)) | ||
for row in result.fetchall() | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const initCalcWasm = async () => { | ||
{{ wasm_exec_js }} | ||
let binaryString = atob("{{file_base64}}"); | ||
let bytes = new Uint8Array(binaryString.length); | ||
for (var i = 0; i < binaryString.length; i++) { | ||
bytes[i] = binaryString.charCodeAt(i); | ||
} | ||
let arrayBuffer = bytes.buffer; | ||
|
||
const go = new window.Go(); | ||
const result = await WebAssembly.instantiate(arrayBuffer, go.importObject); | ||
go.run(result.instance); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
var gw_id = "gwalker-div-{{ gwalker.id }}"; | ||
var props = {{ gwalker.props }}; | ||
console.log(PyGWalkerApp, props, gw_id); | ||
|
||
const initFunc = async () => { | ||
await initCalcWasm(); | ||
}; | ||
|
||
try{ | ||
window.__GW_HASH=props.hashcode; | ||
window.__GW_VERSION=props.version; | ||
PyGWalkerApp.GWalker(props, gw_id); | ||
}catch(e){ console.error(e); } | ||
window.__GW_HASH=props.hashcode; | ||
window.__GW_VERSION=props.version; | ||
initFunc().then(() => { | ||
PyGWalkerApp.GWalker(props, gw_id); | ||
}); | ||
} catch(e) { | ||
console.error(e); | ||
} |
Oops, something went wrong.