Reamer commented on code in PR #4598: URL: https://github.com/apache/zeppelin/pull/4598#discussion_r1194952676
########## zeppelin-interpreter/src/main/java/org/apache/zeppelin/antlr/SqlSplitVisitor.java: ########## @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.zeppelin.antlr; + +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.CharStreams; +import org.antlr.v4.runtime.CommonTokenStream; + +import java.util.ArrayList; +import java.util.List; + +public class SqlSplitVisitor extends SqlBaseVisitor<Object> { + private List<String> list = new ArrayList<>(); Review Comment: Please change the indentation to two spaces. ########## zeppelin-web-angular/src/app/pages/workspace/notebook/paragraph/control/control.component.ts: ########## @@ -193,6 +198,14 @@ export class NotebookParagraphControlComponent implements OnInit, OnChanges { icon: 'api', trigger: () => this.toggleEnabled(), shortCut: `R (Command)` + }, + { + label: 'Debug', + show: this.note.defaultInterpreterGroup==='jdbc' ?true:false, + disabled: this.isEntireNoteRunning, + icon: 'api', + trigger: () => this.trigger(this.debugParagraph), + shortCut: `G (Command)` Review Comment: Why `G`? ########## zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java: ########## @@ -1624,6 +1629,78 @@ public void onSuccess(Paragraph p, ServiceContext context) throws IOException { }); } + private void setResult(Paragraph p,int size,List<String> createTableList){ + List<InterpreterResultMessage> resultMessageList= p.getReturn().message(); + if (p.getReturn().code()== InterpreterResult.Code.SUCCESS){//success + if (resultMessageList.size()==size){ + int successSize=0; + for (InterpreterResultMessage interpreterResultMessage:resultMessageList){ + if(interpreterResultMessage.equals("Query executed successfully. Affected rows : 1\n\n")){ + successSize++; + } + } + if (successSize==size){ + String text="createTableSql\n"; + for (String createTableSql:createTableList){ + text+=createTableSql+"\n"; + } + InterpreterResult interpreterResult=new InterpreterResult(InterpreterResult.Code.SUCCESS, InterpreterResult.Type.TABLE,text); + p.setResult(interpreterResult); + } + } + } + } + + private void debugParagraph(NotebookSocket conn, + ServiceContext context, + Message fromMessage) throws IOException { + String paragraphId = (String) fromMessage.get("id"); + String noteId = connectionManager.getAssociatedNoteId(conn); + String text = (String) fromMessage.get("paragraph"); + //split + List<String> createTableList= SqlSplitVisitor.splitSql(text,paragraphId); + int size=0; + text=""; + for (String createTableSql:createTableList){ + text+=createTableSql+"\n"; + size++; + } + String title = (String) fromMessage.get("title"); + Map<String, Object> params = (Map<String, Object>) fromMessage.get("params"); + Map<String, Object> config = (Map<String, Object>) fromMessage.get("config"); + int finalSize = size; + String finalText = text; + getNotebook().processNote(noteId, + note -> { Review Comment: Please correct the indentation here. ########## zeppelin-web-angular/src/app/pages/workspace/notebook/paragraph/control/control.component.ts: ########## @@ -193,6 +198,14 @@ export class NotebookParagraphControlComponent implements OnInit, OnChanges { icon: 'api', trigger: () => this.toggleEnabled(), shortCut: `R (Command)` + }, + { + label: 'Debug', + show: this.note.defaultInterpreterGroup==='jdbc' ?true:false, Review Comment: ```suggestion show: this.note.defaultInterpreterGroup==='jdbc' ? true : false, ``` ########## zeppelin-interpreter/src/test/java/org/apache/zeppelin/antlr/SqlSplitVisitorTest.java: ########## @@ -0,0 +1,23 @@ +package org.apache.zeppelin.antlr; + +import com.google.gson.Gson; +import org.junit.Test; +import java.util.List; + +public class SqlSplitVisitorTest { + @Test + public void testSplitSql() { + String text = "select id,name from (\n" + + "select id,name from table1\n" + + "union all\n" + + "select id,name from table2\n" + + "union all\n" + + "select id,name from table3\n" + + "union all\n" + + "select id,name from table4\n" + + ")t group by id,name"; + String paragraphId = "paragraph_1683516605896_1391976205"; + List<String> tableSqlList= SqlSplitVisitor.splitSql(text,paragraphId); + System.out.println(new Gson().toJson(tableSqlList)); Review Comment: At least one assertion should be included in the test. Remove `System.out.println`. ########## zeppelin-web-angular/src/app/pages/workspace/notebook/paragraph/paragraph.component.ts: ########## @@ -292,6 +292,44 @@ export class NotebookParagraphComponent extends ParagraphBase implements OnInit, this.editorSetting.isOutputHidden = this.paragraph.config.editorSetting.editOnDblClick; } + debugParagraph(paragraphText?: string, propagated: boolean = false) { + const text = paragraphText || this.paragraph.text; + if (text && !this.isParagraphRunning) { + const magic = SpellResult.extractMagic(text); + + if (this.heliumService.getSpellByMagic(magic)) { + this.runParagraphUsingSpell(text, magic, propagated); + this.runParagraphAfter(text); + } else { + const check = this.ngTemplateAdapterService.preCheck(text); + if (!check) { + this.debugParagraphUsingBackendInterpreter(text); + this.runParagraphAfter(text); + } else { + this.waitConfirmFromEdit = true; + this.nzModalService + .confirm({ + nzTitle: 'Do you want to migrate the Angular.js template?', Review Comment: What is this title? ########## zeppelin-web-angular/src/app/pages/workspace/notebook/paragraph/paragraph.component.ts: ########## @@ -292,6 +292,44 @@ export class NotebookParagraphComponent extends ParagraphBase implements OnInit, this.editorSetting.isOutputHidden = this.paragraph.config.editorSetting.editOnDblClick; } + debugParagraph(paragraphText?: string, propagated: boolean = false) { Review Comment: Are you sure that the method works? ########## zeppelin-web-angular/src/app/pages/workspace/notebook/paragraph/control/control.component.ts: ########## @@ -29,6 +29,9 @@ import { NzModalService } from 'ng-zorro-antd/modal'; import { ActivatedRoute } from '@angular/router'; import { RuntimeInfos } from '@zeppelin/sdk'; import { MessageService } from '@zeppelin/services'; +import { Review Comment: This should be in one line. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@zeppelin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org