Created
December 24, 2020 16:46
-
-
Save francisco-ltech/05e944e52f7ca5c51bce927773a91dd0 to your computer and use it in GitHub Desktop.
Json API endpoint for Delta Lake
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
from deltalake import DeltaTable | |
from flask import request, jsonify | |
app = flask.Flask(__name__) | |
app.config["DEBUG"] = True | |
@app.route('/read-delta-table', methods=['GET']) | |
def home(): | |
dt = DeltaTable("/tmp/delta/students-delta-table/") | |
pd = dt.to_pyarrow_dataset().to_table().to_pandas() | |
json_str = pd.to_json(orient = "records") | |
parsed = json.loads(json_str) | |
return jsonify(parsed) | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment