Commit e038ca6
committed
fix(go): handle empty SchemaBytes for 0-row query results
When databricks-sql-go returns 0-row results, SchemaBytes() can
intermittently return empty bytes due to a bug where the IPC stream
iterator is created with nil schema bytes on the cold-start path
(databricks/databricks-sql-go#312, databricks/databricks-sql-go#327).
Add a fallback that builds an Arrow schema from driver.Rows column
metadata (Columns, ColumnTypeDatabaseTypeName, ColumnTypeNullable)
when SchemaBytes is empty, instead of returning an error.
Why we're not using `databricks/databricks-sql-go#327`:
1. **The fix is incomplete** — as reviewer @vikrantpuppala [noted](databricks/databricks-sql-go#327), `r.resultSetMetadata` is populated lazily, so it can be `nil` when `GetArrowIPCStreams()` is called before `Columns()`/`Next()`, causing `GetArrowSchemaBytes` to silently return `nil, nil` and the bug to persist.
2. **The PR is not approved** and has unresolved review comments (missing tests, duplicated logic, context param ordering).
3. **Our workaround is simple and robust** — we use `driver.Rows.Columns()` + `ColumnTypeDatabaseTypeName()` + `ColumnTypeNullable()`, which are always available regardless of lazy metadata loading.1 parent 8d056d1 commit e038ca6
1 file changed
Lines changed: 75 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
109 | 117 | | |
| 118 | + | |
| 119 | + | |
110 | 120 | | |
111 | 121 | | |
112 | 122 | | |
| |||
130 | 140 | | |
131 | 141 | | |
132 | 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 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
133 | 205 | | |
134 | 206 | | |
135 | 207 | | |
| |||
0 commit comments