cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Generative AI
Explore discussions on generative artificial intelligence techniques and applications within the Databricks Community. Share ideas, challenges, and breakthroughs in this cutting-edge field.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Do non-ASCII characters in file names break document indexing over a Unity Catalog volume?

suranga
Databricks Partner

I spent a few days on a document retrieval problem that turned out to have nothing to do with the retrieval setup, and I want to check whether anyone else has hit the same thing.

Setup: around 40 internal PDF documents in a managed Unity Catalog volume, indexed for question answering. Ordinary text PDFs, not scans. I confirmed that by pulling text out of one of them and getting roughly 77,000 characters.

Symptom: the index reported every file processed with zero errors. Every question came back with nothing retrieved. Not a wrong answer, not a partial one. Empty, and no error anywhere in the chain.

Two things came out of this and I think they are worth separating.

1. "Every file processed, 0 errors" was true and useless

That count measures files enumerated, not text landed. It cannot tell a real extraction apart from a silent empty one. So for several days I had a green status and no working retrieval, with nothing in between to tell me which I had.

What I would want instead is a per-document character or chunk count, and an explicit count of files that indexed to zero retrievable content. If your only health signal cannot distinguish success from silence, it is not a health signal. That holds for any parse-then-index pipeline over a volume, so if you are building one, add the output-side count before you need it rather than after.

2. File names, and this is the part I am actually asking about

The catalog, schema and volume names were all lowercase letters, digits and underscores. Clean ASCII. The file names were not. Six of the documents had Swedish characters in the name, and every file name contained spaces. Names along these lines:

Lรถnepolicy 1995.pdf

Jรคmstรคlldhetspolicy 3054.pdf

Policy fรถr hybridarbete 57.pdf

ASCII is 95 printable characters: the Latin letters, the digits, the space and common punctuation. Everything carrying a mark, so every Swedish, German, French, Polish or Czech letter, sits outside it. Most of a pipeline is character agnostic right up to the one hop where a file name becomes part of a path, a URL, a JSON key or a shell argument, and that is where I would expect this class of bug to live.

So I copied the volume, kept only the documents whose names were plain ASCII, and deliberately kept the spaces, so that non-ASCII characters were the only variable that changed. Same compute, same documents, same configuration.

Being straight about the limits of that: in the run where answers came back correctly, I still had the original volume and the ASCII copy attached at the same time, so an answer could have come from either one. I am rerunning it against the ASCII copy alone before I claim the file names are the cause. I will post the result in this thread either way.

What I am hoping someone can tell me:

  • Has anyone seen non-ASCII characters in file names break document parsing or indexing over a UC volume, silently or otherwise?
  • If you work with Nordic, German or Polish documents, do you normalise file names to ASCII on the way in as a matter of course?
  • Once a file name has been flattened, where do you keep the readable original title? A metadata column alongside the parsed text, or something else?
1 ACCEPTED SOLUTION

Accepted Solutions

suranga
Databricks Partner

Update, as promised: it wasn't the file names.

I had a support case open on this in parallel, and Databricks engineering has now looked into it. They reproduced รฅ, รค, รถ, spaces and accents in their own tests and everything retrieved correctly. They also found that my original volume, Swedish names and all, did answer correctly for a short while right after it was first indexed. So no renaming needed, and those of you who couldn't reproduce it were right.

What actually happened: about a day after the content search index was built, the serving table underneath it lost some required fields. From then on every search failed, and Genie shows that as "no relevant content" rather than an error. My ASCII copy only looked like the fix because it was a fresh index. That also explains the point raised here that all ~40 documents went silent, not just the six with Swedish names. Engineering is working on the root cause and a recovery.

Two things I learned along the way that might save someone else some time:

  1. Volume search in a Genie Agent only runs in Agent mode. My API calls that came back with "no documents are available in this space" were going through the non-agent path. If you call it programmatically, use the Agent mode APIs.
  2. The index status kept saying every file was indexed with no errors while nothing could be retrieved. That's the part I'd most like to see fixed, so I've posted it as an idea: "Surface per-document extraction results in document indexing status, not just file counts". A kudo there helps it get noticed.

Since volume search is still in Public Preview, the suggestion I got for anyone on a tight timeline is the GA route: parse the PDFs with ai_parse_document, embed them with a multilingual model (Swedish matters for us), build an AI Search index over that table and expose it to the agent. It's more to build, but you get a retrieval layer you control and can check per document, which is exactly what was missing here.

Thanks again for all the replies and the testing. Knowing early that the names were unlikely to be the cause helped a lot.

Cheers,
Suranga

View solution in original post

6 REPLIES 6

DoTA
Honored Contributor

Your own caveat is the important bit, so rerunning against the ASCII copy alone is the right move. While you're at it, add two more arms: keep the Swedish letters but drop the spaces, and the other way round. Then you know which of the two it is instead of guessing.

One thing that bites with names like these is Unicode normalization. An รถ can be a single code point or an o plus a combining mark, and files that came off a Mac or a sync tool are often the decomposed form while whatever you type into a path or filter is the composed one. They look the same on screen and don't compare equal. Quick check: list the volume (os.listdir or the SDK) and run unicodedata.normalize('NFC', name) == name on each file. If some come back False, that would be my first suspect, ahead of anything about ASCII itself.

I haven't seen this written up as a known limit for the volume indexing path, so I wouldn't treat it as documented behaviour. For the readable title, what tends to work is ingesting under a generated id (file hash, say) and keeping the original name in a column next to the parsed text. That also gives you the per-document character count you were after, and you can alert on zero.

Isaac_18
Contributor II

Thanks for writing this up properly, @suranga. "0 errors, nothing retrieved" is a really frustrating spot to be in. +1 to @DoTA's normalization check. Here's how I'd split the problem so you know exactly which hop drops the text.

The idea is to check each stage on its own: does the file get listed, does it get read, does it get parsed into actual text. If you parse first and count characters per file, the file name question mostly answers itself.

1. Check the names (NFC vs NFD)

import os, unicodedata

vol = "/Volumes/main/docs/policies"
for name in sorted(os.listdir(vol)):
    nfc = unicodedata.normalize("NFC", name) == name
    ascii_only = name.isascii()
    if not nfc or not ascii_only:
        print(f"{name!r:60} NFC={nfc} ascii={ascii_only}")

2. Parse every file and count what actually comes out

CREATE OR REPLACE TABLE main.docs.parse_health AS
WITH parsed AS (
  SELECT path, length(content) AS bytes, ai_parse_document(content) AS p
  FROM read_files('/Volumes/main/docs/policies/', format => 'binaryFile',
                  pathGlobFilter => '*.pdf')
)
SELECT
  path,
  bytes,
  coalesce(sum(length(e.value:content::string)), 0) AS extracted_chars,
  count(e.value)                                     AS elements,
  to_json(any_value(p:error_status))                 AS errors
FROM parsed,
LATERAL variant_explode_outer(p:document:elements) AS e
GROUP BY path, bytes;

SELECT * FROM main.docs.parse_health ORDER BY extracted_chars;

If the Swedish-named files show real character counts here, then parsing is fine and the problem is further down the chain (chunk ids, the sync into the index, or how the path gets used as a key). If they show 0 or are missing, it's at read or parse time, and you can test one file directly to narrow it down.

3. Take file names out of the critical path

This is a good habit for any document pipeline: use a hash as the id, keep the original name as a column, and never use the name as a key.

SELECT sha2(content, 256) AS doc_id,
       element_at(split(path, '/'), -1) AS original_name,
       ...

You still show users the nice Swedish title, but nothing downstream depends on it being encoded the same way twice.

And yes, the zero-text alert is the part I'd keep no matter what. SELECT count(*) FROM parse_health WHERE extracted_chars = 0 as a SQL alert would have flagged this on day one.

If you rerun the ASCII-only and original volumes with the health table, I'd be curious which stage the counts diverge at. That would make a good bug report if it turns out to be the names.

Mrlaura
New Contributor II

One edge case I'd check is where the file name gets converted from a Unity Catalog path into a URI or an API request.

NFC/NFD differences are one possibility, but UTF-8 percent-encoding (or accidentally encoding an already encoded path) could also introduce a mismatch further down the pipeline.

I'd be careful about normalizing the path string without renaming the actual file. A normalized name might look correct but no longer point to the stored object.

Maybe compare the exact same PDF bytes under both an ASCII name and its original Swedish name, then log the path passed to each stage.

Does your pipeline ever convert the volume path into a URL or use the filename as an index key? That might be a useful place to look.

data_pulse
Contributor

Thanks for the write-up @suranga. I investigated this using managed UC volumes in Databricks. I couldn't reproduce a non-ASCII filename issue, but the tests surfaced a few other ways documents can appear processed successfully while retrieval returns nothing.

1. Verify filenames and file content

I started with seven byte-identical PDFs using ASCII names, spaces, Swedish/Polish characters, NFC/NFD Unicode variants, and a literal %20.

A useful first check:

SELECT
    _metadata.file_name AS filename,
    length AS file_size,
    sha2(content, 256) AS content_hash
FROM read_files(
    '/Volumes/<catalog>/<schema>/<volume>/<dir>/',
    format => 'binaryFile'
)
ORDER BY filename;

Finding: All seven filenames were preserved, and the hashes matched. ai_parse_document extracted identical text, ai_prep_search generated nonempty chunks, and Delta Sync indexes successfully retrieved all seven records.

This also worked when using the original Unicode filenames as primary keys with NFC and NFD remaining distinct.

2. Check extracted text and chunks, not just processing errors

I extended the test to 40 PDFs covering ASCII, Swedish characters, spaces, and NFC/NFD names. I also introduced malformed and blank documents to compare their behavior.

ScenarioNonempty extracted textNonempty chunksobservation
40 valid PDFs40/4040/40All passed
One malformed PDF substituted39/4039/40Per-file conversion error
Valid blank PDF0/10/1No parse/prep error

The blank PDF was the interesting case: parsing and preparation reported no errors, but produced zero text and zero retrieval chunks.A processed-files count alone doesnโ€™t confirm that usable content reached the indexing stage, so Iโ€™d inspect output per file:

WITH parsed AS (
    SELECT
        _metadata.file_name AS filename,
        ai_parse_document(content) AS parsed_doc
    FROM read_files(
        '/Volumes/<catalog>/<schema>/<volume>/<dir>/',
        format => 'binaryFile'
    )
)
SELECT
    filename,
    parsed_doc:error_status AS parse_error,
    ai_prep_search(parsed_doc) AS prepared
FROM parsed;

Check the extracted content, prepared.error_status, and nonempty chunk_to_retrieve values.

3. Query the index directly before troubleshooting the assistant

I tested direct VECTOR and HYBRID queries against Delta Sync indexes, then compared their results with downstream filtering.

Findings:

  • Direct VECTOR and HYBRID retrieval: PASS.
  • Correct downstream filter: 7 records retained.
  • Deliberately incorrect local filter: 0 records retained.

The filter case was a controlled simulation, but it demonstrates how valid index results can disappear downstream.

For a Vector Search index with Databricks-managed query embeddings, you can test directly:

from databricks.vector_search.client import VectorSearchClient

index = VectorSearchClient().get_index(
    endpoint_name="<endpoint>",
    index_name="<catalog>.<schema>.<index>"
)

result = index.similarity_search(
    query_text="<distinctive phrase from PDF>",
    columns=["<id_column>", "<text_column>"],
    num_results=10,
    query_type="HYBRID"
)
print(result)

For self-managed embeddings, provide a compatible query_vector as well. If direct search works but the assistant returns nothing, inspect source selection, metadata filters, document IDs, and path comparisons.

4. Isolate files and verify synchronization

Two additional checks were useful:

  • Batch isolation: split the collection into smaller batches and check per-file extraction and chunk counts. In a controlled fault-injection test, recursive bisection isolated a deliberately failing file in four steps.
  • Index sync: initial and incremental Delta Sync updates both reached COMPLETED, and a newly appended marker record became retrievable. So check actual sync completion and record visibility, not just file-processing status.
  • Permissions: verify the relevant ingestion and query identities, starting with the command below. Include inherited catalog and schema privileges and the search indexโ€™s own access permissions where applicable. I only verified my own identity.
SHOW GRANTS ON VOLUME <catalog>.<schema>.<volume>;

Your three questions

1. Non-ASCII names breaking indexing
Not in my tests: Swedish and Polish characters, spaces, NFC/NFD forms and a literal %20 all survived parsing, chunking and Delta Sync indexing. That covers small PDFs and the building-block functions only, so I canโ€™t rule it out for Knowledge Assistant or Genie volume search. I also havenโ€™t found it documented as a known limit.

2. Normalising to ASCII?
I wouldnโ€™t call it required based on what I saw, so I wouldnโ€™t rename your originals as a first step. What Iโ€™d do is stop depending on the name: generate an ID at ingestion and let nothing downstream use the filename as a key, path or filter value. That avoids the NFC/NFD and encoding mismatches that can appear wherever a name is converted into a URL, key or filter. If you do transform names, donโ€™t normalise the string while the file on disk keeps its old name, or the new string no longer points at the stored object.

3. Where do you keep the readable original title?
In a column next to the parsed text, keyed by a generated ID:

SELECT
    sha2(content, 256)  AS doc_id,         -- stable ASCII key
    _metadata.file_name AS original_name   -- readable title for display
FROM read_files('/Volumes/catalog/schema/volume/dir/', format => 'binaryFile')

Index on doc_id and show original_name to users. In my test this worked, and so did raw filenames as primary keys, so itโ€™s good hygiene rather than a fix. A content hash gives duplicate PDFs the same ID, so add the path to the hash if you have copies under different names.

What stands out in your case

Only 6 of ~40 PDFs had Swedish characters, yet retrieval was empty for the entire collection. If the names were the cause, the 34 ASCII-named files should still have worked, so Iโ€™m particularly interested in a collection-wide ingestion, synchronization or retrieval configuration issue.

Iโ€™d troubleshoot in this order:

  1. Check file discovery and extracted text and chunk counts per PDF. If some fail, isolate them in smaller batches.
  2. Check index synchronization and whether the expected records are present.
  3. Query a distinctive phrase from an ASCII-named PDF directly against the index.
  4. If direct retrieval works, inspect assistant-side source selection and filters.

Limits of these tests
These came from small controlled synthetic PDFs and Delta Sync indexes, not your 77,000-character documents, so size-related limits are untested. They donโ€™t establish the cause in your managed indexing workflow and I couldnโ€™t exercise the Knowledge Assistant or Genie managed volume path in my environment.

okinashchuk
New Contributor III

Short answer from my test: the file names are not the problem. I ran ai_parse_document on a managed volume, and names with Swedish letters and spaces (both NFC and NFD forms) parsed fine, same as data_pulse found.

One thing worth knowing: parse failures don't fail the query. In my run the query succeeded for all 10 files, but 5 of them came back with zero elements and the reason only in error_status ("exceeds the limit of 500" pages, "Unsupported file format", "Document conversion failed"). A blank PDF returned nothing and no error. So "zero errors" may not mean what it looks like. This shows per-file counts:

SELECT element_at(split(path, '/'), -1) AS file,
size(ai_parse_document(content):document:elements::array<variant>) AS elements,
ai_parse_document(content):error_status::string AS error
FROM READ_FILES('/Volumes/<catalog>/<schema>/<volume>/', format => 'binaryFile')
ORDER BY elements;

If every file has elements and no error, parsing is fine and I'd look at indexing, sync or permissions next.

suranga
Databricks Partner

Update, as promised: it wasn't the file names.

I had a support case open on this in parallel, and Databricks engineering has now looked into it. They reproduced รฅ, รค, รถ, spaces and accents in their own tests and everything retrieved correctly. They also found that my original volume, Swedish names and all, did answer correctly for a short while right after it was first indexed. So no renaming needed, and those of you who couldn't reproduce it were right.

What actually happened: about a day after the content search index was built, the serving table underneath it lost some required fields. From then on every search failed, and Genie shows that as "no relevant content" rather than an error. My ASCII copy only looked like the fix because it was a fresh index. That also explains the point raised here that all ~40 documents went silent, not just the six with Swedish names. Engineering is working on the root cause and a recovery.

Two things I learned along the way that might save someone else some time:

  1. Volume search in a Genie Agent only runs in Agent mode. My API calls that came back with "no documents are available in this space" were going through the non-agent path. If you call it programmatically, use the Agent mode APIs.
  2. The index status kept saying every file was indexed with no errors while nothing could be retrieved. That's the part I'd most like to see fixed, so I've posted it as an idea: "Surface per-document extraction results in document indexing status, not just file counts". A kudo there helps it get noticed.

Since volume search is still in Public Preview, the suggestion I got for anyone on a tight timeline is the GA route: parse the PDFs with ai_parse_document, embed them with a multilingual model (Swedish matters for us), build an AI Search index over that table and expose it to the agent. It's more to build, but you get a retrieval layer you control and can check per document, which is exactly what was missing here.

Thanks again for all the replies and the testing. Knowing early that the names were unlikely to be the cause helped a lot.

Cheers,
Suranga