You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/08/26 10:21:49 UTC

(datafusion) branch gh-readonly-queue/main/pr-24634-9a3d35351aaa91a4d22d6cb9dc4ce61c76059dc2 created (now 040b6d0b99)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-24634-9a3d35351aaa91a4d22d6cb9dc4ce61c76059dc2
in repository https://gitbox.apache.org/repos/asf/datafusion.git


      at 040b6d0b99 docs: add runnable examples for `input_file_name()` and `file_row_index()` (#24634)

This branch includes the following new commits:

     new 040b6d0b99 docs: add runnable examples for `input_file_name()` and `file_row_index()` (#24634)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


(datafusion) 01/01: docs: add runnable examples for `input_file_name()` and `file_row_index()` (#24634)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-24634-9a3d35351aaa91a4d22d6cb9dc4ce61c76059dc2
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit 040b6d0b9945a9c9e5c98a4bf3dfdd78990b8f8b
Author: Andrew Lamb <an...@nerdnetworks.org>
AuthorDate: Wed Aug 26 10:21:28 2026 +0000

    docs: add runnable examples for `input_file_name()` and `file_row_index()` (#24634)
    
    ## Which issue does this PR close?
    
    - N/A -- documentation only.
    
    
    ## Rationale for this change
    
    While writing a blog post
    - https://github.com/apache/datafusion-site/pull/203
    
    Which mentiones `file_row_index()` and `input_file_name()` -- I added a
    simple example for the post and I think it would help to have docs in
    the main site too.
    
    
    ## What changes are included in this PR?
    
    Replaces the `sql_example` with
    
    ```sql
    > COPY (SELECT * from values (100), (200), (300)) to '/tmp/foo.parquet';
    
    > select *, input_file_name(), file_row_index() from '/tmp/foo.parquet';
    +---------+-------------------+------------------+
    | column1 | input_file_name() | file_row_index() |
    +---------+-------------------+------------------+
    | 100     | tmp/foo.parquet   | 0                |
    | 200     | tmp/foo.parquet   | 1                |
    | 300     | tmp/foo.parquet   | 2                |
    +---------+-------------------+------------------+
    ```
    
    The same example is used for both functions, since showing them together
    is likely common and I think makes it clear what they do
    
    ## Are these changes tested?
    By CI
    
    ## Are there any user-facing changes?
    
    Yes, but documentation only -- the rendered examples for
    `input_file_name()`
    and `file_row_index()` in the SQL function reference. No API or behavior
    changes.
---
 datafusion/functions/src/core/file_row_index.rs  | 11 ++++++++++-
 datafusion/functions/src/core/input_file_name.rs | 11 ++++++++++-
 docs/source/user-guide/sql/scalar_functions.md   | 22 ++++++++++++++++++++--
 3 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/datafusion/functions/src/core/file_row_index.rs b/datafusion/functions/src/core/file_row_index.rs
index 7b2667a8b8..e76b57e147 100644
--- a/datafusion/functions/src/core/file_row_index.rs
+++ b/datafusion/functions/src/core/file_row_index.rs
@@ -45,7 +45,16 @@ evaluation returns an error.
 "#,
     syntax_example = "file_row_index()",
     sql_example = r#"```sql
-SELECT file_row_index() FROM t;
+> COPY (SELECT * from values (100), (200), (300)) to '/tmp/foo.parquet';
+
+> select *, input_file_name(), file_row_index() from '/tmp/foo.parquet';
++---------+-------------------+------------------+
+| column1 | input_file_name() | file_row_index() |
++---------+-------------------+------------------+
+| 100     | tmp/foo.parquet   | 0                |
+| 200     | tmp/foo.parquet   | 1                |
+| 300     | tmp/foo.parquet   | 2                |
++---------+-------------------+------------------+
 ```"#
 )]
 #[derive(Debug, PartialEq, Eq, Hash)]
diff --git a/datafusion/functions/src/core/input_file_name.rs b/datafusion/functions/src/core/input_file_name.rs
index a47e9daaf8..555c498e57 100644
--- a/datafusion/functions/src/core/input_file_name.rs
+++ b/datafusion/functions/src/core/input_file_name.rs
@@ -38,7 +38,16 @@ evaluated outside a file scan, or was not pushed down into one), direct evaluati
 "#,
     syntax_example = "input_file_name()",
     sql_example = r#"```sql
-SELECT input_file_name() FROM t;
+> COPY (SELECT * from values (100), (200), (300)) to '/tmp/foo.parquet';
+
+> select *, input_file_name(), file_row_index() from '/tmp/foo.parquet';
++---------+-------------------+------------------+
+| column1 | input_file_name() | file_row_index() |
++---------+-------------------+------------------+
+| 100     | tmp/foo.parquet   | 0                |
+| 200     | tmp/foo.parquet   | 1                |
+| 300     | tmp/foo.parquet   | 2                |
++---------+-------------------+------------------+
 ```"#
 )]
 #[derive(Debug, PartialEq, Eq, Hash)]
diff --git a/docs/source/user-guide/sql/scalar_functions.md b/docs/source/user-guide/sql/scalar_functions.md
index 44e697569a..bdc8efb1bd 100644
--- a/docs/source/user-guide/sql/scalar_functions.md
+++ b/docs/source/user-guide/sql/scalar_functions.md
@@ -5960,7 +5960,16 @@ file_row_index()
 #### Example
 
 ```sql
-SELECT file_row_index() FROM t;
+> COPY (SELECT * from values (100), (200), (300)) to '/tmp/foo.parquet';
+
+> select *, input_file_name(), file_row_index() from '/tmp/foo.parquet';
++---------+-------------------+------------------+
+| column1 | input_file_name() | file_row_index() |
++---------+-------------------+------------------+
+| 100     | tmp/foo.parquet   | 0                |
+| 200     | tmp/foo.parquet   | 1                |
+| 300     | tmp/foo.parquet   | 2                |
++---------+-------------------+------------------+
 ```
 
 ### `get_field`
@@ -6032,7 +6041,16 @@ input_file_name()
 #### Example
 
 ```sql
-SELECT input_file_name() FROM t;
+> COPY (SELECT * from values (100), (200), (300)) to '/tmp/foo.parquet';
+
+> select *, input_file_name(), file_row_index() from '/tmp/foo.parquet';
++---------+-------------------+------------------+
+| column1 | input_file_name() | file_row_index() |
++---------+-------------------+------------------+
+| 100     | tmp/foo.parquet   | 0                |
+| 200     | tmp/foo.parquet   | 1                |
+| 300     | tmp/foo.parquet   | 2                |
++---------+-------------------+------------------+
 ```
 
 ### `try_cast_to_type`


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org