byzer-lang icon indicating copy to clipboard operation
byzer-lang copied to clipboard

MLSQL Mod设计

Open allwefantasy opened this issue 3 years ago • 1 comments

用户可以用MLSQL语言编写Lib库,从而实现强大生态的构建,也能提供海量示例。

打包格式

MLSQL Lib库未来会支持Github/Jar包两种方式分发。

  1. Github 主要用于公有分发,构筑良好的生态。
  2. Jar包主要用于企业私有分发,保证源码安全。两者会共享相同的目录结构。

Lib目录格式

  1. 根目录必须包含package.json

使用范例

github 使用范例

-- 导入Lib库,指定commit id, 并给库取别名
-- 第一次import 根据网络情况可能会很慢
include lib.`github.com/allwefantasy/mlsql-example` 
where commit="625643d21187ff486c58579161182c9414ec71ec" 
and alias="example";

-- 加载数据集
load delta.`python_data.vega_datasets` 
as vega_datasets;

-- 使用第三方库计算
set targetTable="vega_datasets" ;
set size="1" ;
include local.`example.pkg.util.limit_table`;

其中,对于引用lib库,默认会clone到引擎目录下的 __mlsql__/deps目录下。

Jar 使用范例

-- 导入jar库, 并给库取别名
include jar.`mlsql-example` 
where alias="example";

-- 加载数据集
load delta.`python_data.vega_datasets` 
as vega_datasets;

-- 使用第三方库计算
set targetTable="vega_datasets" ;
set size="1" ;
include local.`example.pkg.util.limit_table`;

其中,对于引用lib库,默认会到引擎目录下的 __mlsql__/deps目录下寻找。

allwefantasy avatar May 06 '21 00:05 allwefantasy

package.json格式:

{
    "version": "1.0",
    "main": "mlsql-example.main",
    "init": "mlsql-example.init",
    "pythonDeps":[
       {
         "name":"pandas",
         "version":">=2.1"
       }
     ],
   "deps":[
       {
         "name":"github.com/allwefantasy/lib-util",
         "version":"625643d21187ff486c58579161182c9414ec71ec"
       }
     ]
}

allwefantasy avatar May 06 '21 03:05 allwefantasy