geoffreyclaude commented on code in PR #19265:
URL: https://github.com/apache/datafusion/pull/19265#discussion_r2618438652


##########
docs/source/library-user-guide/extending-sql.md:
##########
@@ -0,0 +1,339 @@
+<!---
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+# Extending DataFusion's SQL Syntax
+
+DataFusion provides a flexible extension system that allows you to customize 
SQL
+parsing and planning without modifying the core codebase. This is useful when 
you
+need to:
+
+- Support custom operators from other SQL dialects (e.g., PostgreSQL's `->` 
for JSON)
+- Add custom data types not natively supported
+- Implement SQL constructs like `TABLESAMPLE`, `PIVOT`/`UNPIVOT`, or 
`MATCH_RECOGNIZE`
+
+## Architecture Overview
+
+When DataFusion processes a SQL query, it goes through these stages:
+
+```text
+┌─────────────┐    ┌─────────┐    ┌───────────────────────────────┐    
┌─────────────┐
+│ SQL String  │───▶│ Parser  │───▶│ SqlToRel (SQL to LogicalPlan) │───▶│ 
LogicalPlan │
+└─────────────┘    └─────────┘    └───────────────────────────────┘    
└─────────────┘
+                                              │
+                                              │ uses
+                                              ▼
+                                  ┌───────────────────────┐
+                                  │  Extension Planners   │
+                                  │  • ExprPlanner        │
+                                  │  • TypePlanner        │
+                                  │  • RelationPlanner    │
+                                  └───────────────────────┘
+```
+
+The extension planners intercept specific parts of the SQL AST during the
+`SqlToRel` phase and allow you to customize how they are converted to 
DataFusion's
+logical plan.
+
+## Extension Points
+
+DataFusion provides three planner traits for extending SQL:
+
+| Trait             | Purpose                                 | Registration 
Method                        |
+| ----------------- | --------------------------------------- | 
------------------------------------------ |
+| `ExprPlanner`     | Custom expressions and operators        | 
`ctx.register_expr_planner()`              |

Review Comment:
   `[RelationPlanner]` currently links to a `The requested resource does not 
exist` page at 
https://docs.rs/datafusion/latest/datafusion/logical_expr/planner/trait.RelationPlanner.html,
 but I suppose this is expected until the next release? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to