Skip to content

Commit d68a822

Browse files
committed
basic support
1 parent 78a3a92 commit d68a822

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/dialect/databricks.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use crate::dialect::Dialect;
18+
use crate::dialect::{Dialect, Precedence};
19+
use crate::parser::{Parser, ParserError};
20+
use crate::tokenizer::Token;
1921

2022
/// A [`Dialect`] for [Databricks SQL](https://www.databricks.com/)
2123
///
@@ -38,6 +40,15 @@ impl Dialect for DatabricksDialect {
3840
matches!(ch, 'a'..='z' | 'A'..='Z' | '0'..='9' | '_')
3941
}
4042

43+
fn get_next_precedence(&self, parser: &Parser) -> Option<Result<u8, ParserError>> {
44+
let token = parser.peek_token();
45+
// : is used for JSON path access
46+
match token.token {
47+
Token::Colon => Some(Ok(self.prec_value(Precedence::Period))),
48+
_ => None,
49+
}
50+
}
51+
4152
fn supports_filter_during_aggregation(&self) -> bool {
4253
true
4354
}

src/parser/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3567,7 +3567,8 @@ impl<'a> Parser<'a> {
35673567
expr: Box::new(expr),
35683568
})
35693569
} else if Token::LBracket == *tok && self.dialect.supports_partiql()
3570-
|| (dialect_of!(self is SnowflakeDialect | GenericDialect) && Token::Colon == *tok)
3570+
|| (dialect_of!(self is SnowflakeDialect | GenericDialect | DatabricksDialect)
3571+
&& Token::Colon == *tok)
35713572
{
35723573
self.prev_token();
35733574
self.parse_json_access(expr)

0 commit comments

Comments
 (0)