@@ -2572,11 +2572,17 @@ fn parse_create_indices_with_operator_classes() {
25722572 IndexType :: SPGiST ,
25732573 IndexType :: Custom ( "CustomIndexType" . into ( ) ) ,
25742574 ] ;
2575- let operator_classes: [ Option < Ident > ; 4 ] = [
2575+ let operator_classes: [ Option < ObjectName > ; 4 ] = [
25762576 None ,
2577- Some ( "gin_trgm_ops" . into ( ) ) ,
2578- Some ( "gist_trgm_ops" . into ( ) ) ,
2579- Some ( "totally_not_valid" . into ( ) ) ,
2577+ Some ( ObjectName ( vec ! [ ObjectNamePart :: Identifier ( Ident :: new(
2578+ "gin_trgm_ops" ,
2579+ ) ) ] ) ) ,
2580+ Some ( ObjectName ( vec ! [ ObjectNamePart :: Identifier ( Ident :: new(
2581+ "gist_trgm_ops" ,
2582+ ) ) ] ) ) ,
2583+ Some ( ObjectName ( vec ! [ ObjectNamePart :: Identifier ( Ident :: new(
2584+ "totally_not_valid" ,
2585+ ) ) ] ) ) ,
25802586 ] ;
25812587
25822588 for expected_index_type in indices {
@@ -2713,6 +2719,36 @@ fn parse_create_indices_with_operator_classes() {
27132719 }
27142720}
27152721
2722+ #[ test]
2723+ fn parse_create_index_with_schema_qualified_operator_class ( ) {
2724+ let sql = "CREATE INDEX my_index ON my_table USING HNSW (embedding public.vector_cosine_ops)" ;
2725+
2726+ match pg ( ) . verified_stmt ( sql) {
2727+ Statement :: CreateIndex ( CreateIndex { columns, .. } ) => {
2728+ assert_eq ! ( 1 , columns. len( ) ) ;
2729+ let idx_col = & columns[ 0 ] ;
2730+
2731+ // Verify the column name
2732+ match & idx_col. column . expr {
2733+ Expr :: Identifier ( ident) => {
2734+ assert_eq ! ( "embedding" , ident. value) ;
2735+ }
2736+ _ => panic ! ( "Expected identifier expression" ) ,
2737+ }
2738+
2739+ // Verify the schema-qualified operator class
2740+ assert_eq ! (
2741+ Some ( ObjectName ( vec![
2742+ ObjectNamePart :: Identifier ( Ident :: new( "public" ) ) ,
2743+ ObjectNamePart :: Identifier ( Ident :: new( "vector_cosine_ops" ) ) ,
2744+ ] ) ) ,
2745+ idx_col. operator_class
2746+ ) ;
2747+ }
2748+ _ => unreachable ! ( ) ,
2749+ }
2750+ }
2751+
27162752#[ test]
27172753fn parse_create_bloom ( ) {
27182754 let sql =
0 commit comments