@@ -132,6 +132,9 @@ func (c *cc) convertCreate_virtual_table_stmtContext(n *parser.Create_virtual_ta
132132 case "fts5" :
133133 // https://www.sqlite.org/fts5.html
134134 return c .convertCreate_virtual_table_fts5 (n )
135+ case "rtree" :
136+ // https://www.sqlite.org/rtree.html
137+ return c .convertCreate_virtual_table_rtree (n )
135138 default :
136139 return todo (
137140 fmt .Sprintf ("create_virtual_table. unsupported module name: %q" , moduleName ),
@@ -140,6 +143,38 @@ func (c *cc) convertCreate_virtual_table_stmtContext(n *parser.Create_virtual_ta
140143 }
141144}
142145
146+ func (c * cc ) convertCreate_virtual_table_rtree (n * parser.Create_virtual_table_stmtContext ) ast.Node {
147+ stmt := & ast.CreateTableStmt {
148+ Name : parseTableName (n ),
149+ IfNotExists : n .EXISTS_ () != nil ,
150+ }
151+
152+ for i , arg := range n .AllModule_argument () {
153+ columnExpr , ok := arg .Expr ().(* parser.Expr_qualified_column_nameContext )
154+ if ! ok {
155+ continue
156+ }
157+
158+ columnName := columnExpr .Column_name ().GetText ()
159+
160+ col := ast.ColumnDef {
161+ Colname : identifier (columnName ),
162+ IsNotNull : true ,
163+ }
164+
165+ // first argument in the rtree is an integer (ID)
166+ // https://www.sqlite.org/rtree.html#column_naming_details
167+ if i == 0 {
168+ col .TypeName = & ast.TypeName {Name : "integer" }
169+ } else {
170+ col .TypeName = & ast.TypeName {Name : "real" }
171+ }
172+
173+ stmt .Cols = append (stmt .Cols , & col )
174+ }
175+ return stmt
176+ }
177+
143178func (c * cc ) convertCreate_virtual_table_fts5 (n * parser.Create_virtual_table_stmtContext ) ast.Node {
144179 stmt := & ast.CreateTableStmt {
145180 Name : parseTableName (n ),
0 commit comments