Select to view content in your preferred language

Survey123 queries fail at 797 fields with “SQL query is nested too deeply” on a 907-field parent layer

143
3
a week ago
ChristopherVan_de_Wyngard
Emerging Contributor

We are experiencing a production issue with a long-running Survey123 survey whose parent hosted feature layer contains 907 fields and currently has approximately 503 records.

The survey and feature layer worked previously, but multiple Survey123 and ArcGIS Online functions recently began failing with the following error:

Cannot perform query. Invalid query parameters.

'SQL query is nested too deeply. Rewrite the query or break it up
into smaller queries.' parameter is invalid

Error Code: 400

We performed controlled testing through the ArcGIS REST Services Directory to isolate the problem.

Controlled REST query results

Test settings:

where=1=1
returnGeometry=false
resultRecordCount=1
Request method=POST

Results:

796 explicitly requested fields = succeeds
797 explicitly requested fields = fails
907 fields / outFields=*        = fails

We tested multiple different field combinations rather than only the first fields in the schema.

The following all succeeded:

  • First 796 fields
  • Last-heavy combination of 796 fields
  • Middle-field combination of 796 fields
  • Split beginning/end combination of 796 fields
  • Evenly distributed 796 fields
  • Multiple randomized combinations of 796 fields

Multiple different combinations containing exactly 797 fields failed with the same nested-SQL error.

We also tested the field located at position 797:

  • That field works when requested by itself.
  • The first 795 fields plus that field also work because the total is 796.

Therefore, we have not identified a particular defective field. The failure appears to be based on the total number of requested fields.

Survey123 Field App

Inbox refresh fails with:

Cannot perform query.
Invalid query parameters.
Code 400

We tested two different Field App versions, and both produced the same result:

Survey123 Field App 3.1
Survey123 Field App 3.25

Survey123 website

The Survey123 Data page recognizes the record count and displays approximately:

503/503

However, the attribute table is blank. Because the rows contain no visible data, records cannot be selected for report generation.

ArcGIS Map Viewer

The parent-layer geometries and record count load, but the attribute table is blank.

Using Chrome Developer Tools, we confirmed the attribute table sends this query:

where=1=1
outFields=*
returnGeometry=false
resultRecordCount=50
f=pbf

Because outFields=* requests all 907 fields, the table does not populate.

A configured Map Viewer pop-up still works. We captured its requested field list and confirmed that it requests only 201 fields, not all 907.

Survey123 Feature Report service

A report request for one specific record was submitted successfully and received a valid job ID. The job then failed during preparation:

jobStatus: esriJobFailed
detailedStatus: prepareFailed
progress: 0

The report request was limited to one ObjectID:

"queryParameters": {
  "objectIds": "5068"}

The returned message was:

An error occurred when querying data from the feature layer.

400: Cannot perform query. Invalid query parameters.

'SQL query is nested too deeply. Rewrite the query or break it up
into smaller queries.' parameter is invalid

This occurred before the Word document was created.

ArcGIS API for Python

A custom Python export process also failed while querying the same single parent record with:

ft.query(
    where="objectid=5068",
    out_fields="*",
    return_geometry=False)

The ArcGIS API for Python returned the same Code 400 and nested-SQL error.

Changing the Python process so it requests only the ObjectID and GlobalID allows it to avoid that specific full-width query.

Confirmed behavior summary

Operation Requested fields Result
REST query796Succeeds
REST query797Fails
REST query* / 907Fails
Map Viewer pop-up201Succeeds
Map Viewer attribute table* / 907Blank
Survey123 Data pageFull parent schemaBlank
Survey123 InboxFull parent schemaCode 400
Feature Report for one ObjectIDFull parent record preparationFails
Python query with out_fields="*"907Fails

Questions for Esri

  1. Is there a known ArcGIS Online or Survey123 issue that causes hosted feature-layer queries to fail when 797 or more fields are requested?
  2. Has there been a recent backend or query-processing change that could explain why this survey worked previously with the same schema?
  3. Is the 796/797 boundary associated with a known defect?
  4. Can Esri review the hosted service logs to determine why the generated query is considered “nested too deeply”?
  5. Is there a supported workaround for Survey123 Inbox, the Data page, and Feature Reports other than rebuilding the survey with fewer parent-layer fields?
  6. Can these Survey123 operations be changed to request attributes in smaller batches rather than using the complete parent schema?

At this time, the only confirmed distinction is that operations requesting a limited field list continue to work, while operations requesting 797 or more fields fail.

3 Replies
abdhassa24
Occasional Contributor

Hey, I also noticed this issue on a survey123 with a similar number of fields as yourself. I believe something has changed on the backend that is causing this issue for services with close to a 1000 columns.

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hey @ChristopherVan_de_Wyngard @abdhassa24

Thank you for reporting this! There was a fix applied to ArcGIS Online last night that addresses this issue. Testing on our end we're no longer able to reproduce in our sample ArcGIS Online org.

Are you still seeing the issue on your end? 

Thank you,
Zach
0 Kudos
ChristopherVan_de_Wyngard
Emerging Contributor

Thank you, Zach. As always, I truly appreciate the excellent work you and the ESRI team do. Thank you very much for looking into this issue and getting it resolved. After the fix was implemented, we confirmed that the issue is now resolved on our end as well.

0 Kudos