Skip to content

Commit

Permalink
feat:add sql debug feature
Browse files Browse the repository at this point in the history
  • Loading branch information
duanxiaoqiu committed May 18, 2023
1 parent be82be7 commit 6dd002d
Show file tree
Hide file tree
Showing 25 changed files with 2,359 additions and 0 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions docs/interpreter/jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,63 @@ select @v
```
Returns value of `v` which is set in the mysql interpreter's *default.precode*.

## Sql Debug
As we know,we develop in java and c, if the actual result is not same to our's expect result, we can add breakPoint and debug it find the reason or add log find the reason also.The feature of sql debug is also let you debug your sql to find it.

for example

```sql
%jdbc_interpreter_name
select * from (
select name,`age` from test_db.user_info_01
union ALL
select name,`age` from test_db.user_info_02
union ALL
select name,`age` from test_db.user_info_03
)t group by name,`age`
```

<img src="{{BASE_PATH}}/assets/themes/zeppelin/img/docs-img/query_table_result.png" />

<img src="{{BASE_PATH}}/assets/themes/zeppelin/img/docs-img/new_ui_query_table_result.png" />

but the data of 'xiaohe' should not in it,if we want find which table create the data of 'xiaohe',most of us run three times by manually,because it has three tables.

```sql
%jdbc_interpreter_name
select name,`age` from test_db.user_info_01 where name='xiaohe'
```

```sql
%jdbc_interpreter_name
select name,`age` from test_db.user_info_02 where name='xiaohe'
```

```sql
%jdbc_interpreter_name
select name,`age` from test_db.user_info_03 where name='xiaohe'
```

if the sql is more complex,the action must more complexed.if there is a solution to quickly find this problem?let we introduce the feature of sql debug

firstly,add your sql and click the button of debug paragraph,just like this

<img src="{{BASE_PATH}}/assets/themes/zeppelin/img/docs-img/debug_paragraph.png" />

<img src="{{BASE_PATH}}/assets/themes/zeppelin/img/docs-img/new_ui_debug_paragraph.png" />

then it will return result like this

<img src="{{BASE_PATH}}/assets/themes/zeppelin/img/docs-img/debug_result.png" />

<img src="{{BASE_PATH}}/assets/themes/zeppelin/img/docs-img/new_ui_debug_result.png" />

then we can query the table of created to find the reason

```sql
%jdbc_interpreter_name
select * from test_zeppelin.tmp_zeppelin_paragraph_1683297437359_1950110405_1 where name='xiaohe'
```

## Examples
Here are some examples you can refer to. Including the below connectors, you can connect every databases as long as it can be configured with it's JDBC driver.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public enum OP {

FOLDER_RENAME,

DEBUG_PARAGRAPH,

RUN_PARAGRAPH, // [c-s] run paragraph
// @param id paragraph id
// @param paragraph paragraph content.ie. script
Expand Down
1 change: 1 addition & 0 deletions zeppelin-distribution/src/bin_license/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ The following components are provided under Apache License.
(Apache 2.0) Dropwizard Jackson Integration for Metrics (io.dropwizard.metrics:metrics-json:4.1.14) - https://github.com/dropwizard/metrics/blob/release/4.1.x/LICENSE
(Apache 2.0) Dropwizard Metrics Health Checks (io.dropwizard.metrics:metrics-healthchecks:4.1.14) - https://github.com/dropwizard/metrics/blob/release/4.1.x/LICENSE
(Apache 2.0) Dropwizard Metrics Integration with JMX (io.dropwizard.metrics:metrics-jmx:4.1.14) - https://github.com/dropwizard/metrics/blob/release/4.1.x/LICENSE
(Apache 2.0) antlr4-runtime (org.antlr:antlr4-runtime:4.7.2 - https://github.com/antlr/antlr4)

========================================================================
MIT licenses
Expand Down
23 changes: 23 additions & 0 deletions zeppelin-interpreter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<sisu.plexus.version>0.3.4</sisu.plexus.version>
<jline.version>2.14.3</jline.version>
<atomix.version>3.0.0-rc4</atomix.version>
<antlr4.version>4.7.2</antlr4.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -218,6 +219,12 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>${antlr4.version}</version>
</dependency>
</dependencies>

<build>
Expand All @@ -242,6 +249,22 @@
<dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
</configuration>
</plugin>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${antlr4.version}</version>
<configuration>
<visitor>true</visitor>
</configuration>
<executions>
<execution>
<id>antlr</id>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<resources>
Expand Down

0 comments on commit 6dd002d

Please sign in to comment.