Commit 28d6a13
[PECOBLR-1746] Implementing support for listing procedures (#1238)
## Description
Implements `getProcedures` and `getProcedureColumns` in
`DatabricksDatabaseMetaData` by querying `information_schema.routines`
and `information_schema.parameters` via SQL.
Unlike other metadata operations that use `SHOW` commands or Thrift
RPCs, these use direct SQL SELECT queries against `information_schema`
views. This works for both Thrift and SEA transports.
**getProcedures:**
- Queries `information_schema.routines` filtered by `routine_type =
'PROCEDURE'`
- Returns 9-column JDBC-spec result set (PROCEDURE_CAT, PROCEDURE_SCHEM,
PROCEDURE_NAME, reserved x3, REMARKS, PROCEDURE_TYPE, SPECIFIC_NAME)
- PROCEDURE_TYPE is always `procedureNoResult` (1)
**getProcedureColumns:**
- Queries `information_schema.parameters` JOINed with
`information_schema.routines` to filter for procedures
- Returns 20-column JDBC-spec result set with parameter metadata
- Maps `parameter_mode` (IN/OUT/INOUT) to JDBC COLUMN_TYPE constants
(1/4/2)
- Maps Databricks type names to `java.sql.Types` codes via existing
`getCode()`
**Catalog resolution:**
- NULL catalog → queries `system.information_schema.routines`
(cross-catalog)
- Specific catalog → queries `<catalog>.information_schema.routines`
- Empty string → returns empty result set
**Shared SQL builders** in `CommandConstants` eliminate duplication
between SDK and Thrift clients.
## Testing
**Unit tests** (`DatabricksMetadataSdkClientTest`):
- 4 parameterized tests for `listProcedures` SQL generation
(catalog+schema+name, null schema, null name, null catalog)
- 3 parameterized tests for `listProcedureColumns` SQL generation (all
filters, partial filters, all nulls)
**Integration test**
(`MetadataIntegrationTests#testGetProceduresAndProcedureColumns`):
- Creates a procedure `jdbc_test_compute_area(x DOUBLE, y DOUBLE, OUT
area DOUBLE)` with COMMENT
- Verifies `getProcedures` returns correct name, schema, catalog,
remarks, type
- Verifies `getProcedureColumns` returns 3 params with correct
COLUMN_TYPE (IN=1, OUT=4), DATA_TYPE (DOUBLE=8), ordinal positions
- Tests column name filtering
- Cleans up procedure after test
- WireMock stubs recorded for REPLAY mode
**Existing tests:** All 248 `DatabricksDatabaseMetaDataTest` + 51
`DatabricksMetadataSdkClientTest` pass.
## Additional Notes to the Reviewer
- `information_schema.parameters` is used (not `routine_columns`)
because `routine_columns` contains table-valued function output columns,
not procedure parameters.
- NULLABLE is always `procedureNullableUnknown` (2) since the server
does not track parameter nullability.
- When catalog is NULL, `system.information_schema` is queried which
requires system table access permissions. If the user lacks this
permission, the driver returns an empty result set. This will be
addressed server-side in a future release.
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent dd0c7b9 commit 28d6a13
31 files changed
Lines changed: 1323 additions & 65 deletions
File tree
- src
- main/java/com/databricks/jdbc
- api/impl
- common
- dbclient
- impl
- common
- sqlexec
- thrift
- test
- java/com/databricks/jdbc
- api/impl
- common
- dbclient/impl/sqlexec
- integration/fakeservice/tests
- resources
- cloudfetchapi/metadataintegrationtests/testgetproceduresandprocedurecolumns/mappings
- sqlexecapi/metadataintegrationtests/testgetproceduresandprocedurecolumns/mappings
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
Lines changed: 17 additions & 59 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | 895 | | |
911 | 896 | | |
912 | 897 | | |
| |||
916 | 901 | | |
917 | 902 | | |
918 | 903 | | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
957 | 912 | | |
958 | 913 | | |
959 | 914 | | |
| |||
967 | 922 | | |
968 | 923 | | |
969 | 924 | | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | | - | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
976 | 934 | | |
977 | 935 | | |
978 | 936 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
198 | 206 | | |
199 | 207 | | |
200 | 208 | | |
| |||
225 | 233 | | |
226 | 234 | | |
227 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
228 | 248 | | |
229 | 249 | | |
230 | 250 | | |
| |||
618 | 638 | | |
619 | 639 | | |
620 | 640 | | |
| 641 | + | |
621 | 642 | | |
622 | | - | |
| 643 | + | |
623 | 644 | | |
624 | 645 | | |
625 | 646 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
135 | 171 | | |
136 | 172 | | |
137 | 173 | | |
| |||
Lines changed: 109 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | 16 | | |
11 | 17 | | |
| |||
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
29 | 138 | | |
0 commit comments