JSPM

  • Created
  • Published
  • Downloads 36
  • Score
    100M100P100Q79020F
  • License SEE LICENSE IN LICENSE.md

SQL Frames - Slice Vector REPL App

Package Exports

  • @sqlframes/repl-app
  • @sqlframes/repl-app/client/dependencies
  • @sqlframes/repl-app/dependencies/all
  • @sqlframes/repl-app/dependencies/all_runtime
  • @sqlframes/repl-app/dependencies/required_charts
  • @sqlframes/repl-app/dependencies/required_model
  • @sqlframes/repl-app/dependencies/required_ui
  • @sqlframes/repl-app/styles
  • @sqlframes/repl-app/styles/index
  • @sqlframes/repl-app/styles/themes/dark
  • @sqlframes/repl-app/styles/themes/light

Readme

SQL Frames - REPL App

This is a REPL application for evaluating and displaying SQL Frames.

This README provides a quick introduction to the REPL application.

The REPL contains input and output sections referred to as STDIN and STDOUT.

STDIN

STDIN is provided using the monaco editor. Any valid JavaScript can be specified. Any value that needs to be displayed should be explicitly returned. For example,

const df = DataFrame.fromURL('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.csv');
const { groupBy, agg: { max }, where: { eq }} = SQL;
return df.gdf(groupBy('type'),max('mag'));

STDOUT

Any returned value will be displayed in the STDOUT. The return values are displayed as follows

  1. Individual values are displayed using a viewer specific to the type (class) of that value if available. For example, all the Data Frames in SQL Frames have a viewer that can display data in tabular format.
  2. An array is displayed top to bottom with the elemenst stacked vertically.
  3. A JavaScript object (e.g: { x : 42 } ) is displayed with the field names as tabs each containing the corresponding field value.

It is possible to nest arrays and objects to create complex UI.

Special Variables

  1. S - Scratch

Even though this is called REPL, it doesn't provide a LOOP to repeatedly evaluate code. Instead, the existing code needs to be replaced with new code and re-executed. Sometimes it is desirable to retain the values computed for subsequent execution. It is possible to store any value into a special variable called S (for scratch). For example, a DataFrame based on remote data can be fetched once and stored so it is available for subsequent data exploration. For example, the above code is rewritten to make use of storing the Data Frame as a scratch variable for subsequent evaluation.

if(!S.df) {
    const df = DataFrame.fromURL('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.csv');
    S.df = df;
}
const df = S.df;
const { groupBy, agg: { max }, where: { eq }} = SQL;
return df.gdf(groupBy('type'),max('mag'));
  1. C - Cell

The C variable provides some utility functions.

i. C.NONE can be returned to display nothing.

ii. await C.delay(milliseconds,value) can be used to delay certain amount of time and then optionally return a value.

iii. C.md can be used to display markup.

return C.md`Hello **SQL Frames**`