Byzer 语句执行原理解析
load excel.`./example-data/excel/hello_world.xlsx`
where header="true"
as hello_world;
select hello from hello_world as output;
Byzer 是按下面的方式执行的:
在执行一条语句的时候,系统会做两件事情:
判断条件有三个:
所以根据前面的描述,Byzer 在执行 第一条 load 语句的时候,此时情况是:
接着 Byzer 执行第二条 select 语句,此时情况是:
这个时候 Byzer 会将 重组后的 AST 提交给 Runtime 执行数据计算。
从上面的逻辑我们可以得出如下几个结论:
对于如下代码:
load excel.`./example-data/excel/hello_world.xlsx`
where header="true"
as hello_world;
select hello from hello_world where name="yes" as table1;
select * from table1 as output;
当我们将他们放在 notebook 里的三个 Cell 中,然后分别执行,当我们再执行第三条语句的时候
对于如下代码:
load excel.`./example-data/excel/hello_world.xlsx`
where header="true"
as hello_world;
select hello from hello_world where name="yes" as table1;
select * from hello_world as output;
第三条语句只依赖第一条语句产生的表, 所以第三条语句会查找到第一条语句的 AST 然后重组成新的 AST 来执行。第二条语句则仅仅生成 AST,但不会参与到最后的计算。
那如何让第三条语句变快呢? 那就是执行 save 动作,切断查找依赖:
Notebook Cell 1:
load excel.`./example-data/excel/hello_world.xlsx`
where header="true"
as hello_world;
select hello from hello_world where name="yes" as table1;
save overwrite table1 as parquet.`/tmp/table1`;
load parquet.`/tmp/table1` as table2;
Notebook Cell 2:
select * from table2 as output;
当我们执行第二个Cell 的时候, 他会去找 table2, table2 是从 parquet 里加载的,所以此时直接从parquet 里那就好了,不需要 再到 table1 去取数据,从而触发 table1 的实际执行。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有