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

View containing JSON_TABLE does not return JSON

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.6.16
    • 10.6
    • Views
    • None
    • Ubuntu 20.04

    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

        Activity

          People

            holyfoot Alexey Botchkov
            vdg@plan-bee.ch Walter van der Geest
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.