Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-34081

View containing JSON_TABLE does not return JSON

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 10.6.16, 10.6, 10.11, 11.4, 11.8
    • 10.11, 11.4, 11.8
    • JSON, Views
    • None
    • Ubuntu 20.04
    • Q3/2025 Maintenance, Q4/2025 Server Maintenance

    Description

      Extracting part of a JSON with JSON_TABLE works in direct query but not as view.

      SELECT * FROM JSON_TABLE('
      [
        {
          "caption": "First Element",
          "value": 1
        },
        {
          "caption": "Second Element",
          "value": 2
        }
      ]
      ', '$[*]' COLUMNS(
      	caption VARCHAR(200) PATH '$.caption', 
      	whole_block JSON PATH '$')) t;
      

      brings

      caption         whole_block                                               
      --------------  ----------------------------------------------------------
      First Element   {                                                         
                          "caption": "First Element",                           
                          "value": 1                                            
                        }                                                       
      Second Element  {                                                         
                          "caption": "Second Element",                          
                          "value": 2                                            
                        }                                                       
      

      which is what I expected.

      Creating the view out if it does not return the block:

      CREATE OR REPLACE VIEW test_view AS SELECT * FROM JSON_TABLE('
      [
        {
          "caption": "First Element",
          "value": 1
        },
        {
          "caption": "Second Element",
          "value": 2
        }
      ]
      ', '$[*]' COLUMNS(
      	caption VARCHAR(200) PATH '$.caption', 
      	whole_block JSON PATH '$')) t;
       
      SELECT * FROM test_view;
      

      Result:

      caption         whole_block  
      --------------  -------------
      First Element   (NULL)       
      Second Element  (NULL)       
      

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              vdg@plan-bee.ch Walter van der Geest
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.