question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Table output cannot handle non-toplevel arrays

See original GitHub issue

There appears to be an issue where the -o table type cannot handle non-toplevel arrays. This is visible by running through some steps from an upcoming conceptual tutorial document:

az group create --name TutorialResources --location eastus

az vm create --resource-group TutorialResources \
          --name TutorialVM1 \
          --image UbuntuLTS \
          --generate-ssh-keys \
          --verbose

NIC_ID=$(az vm show -n TutorialVM1 -g TutorialResources \
          --query 'networkProfile.networkInterfaces[].id' \
          -o tsv)

        az network nic show --ids $NIC_ID \
          -g TutorialResources \
          --query '{IP:ipConfigurations[].publicIpAddress.id, Subnet:ipConfigurations[].subnet.id}' \
          -o json
{
  "IP": [
    "/subscriptions/.../resourceGroups/TutorialResources/providers/Microsoft.Network/publicIPAddresses/TutorialVM1PublicIP"
  ],
  "Subnet": [
    "/subscriptions/.../resourceGroups/TutorialResources/providers/Microsoft.Network/virtualNetworks/TutorialVM1VNET/subnets/TutorialVM1Subnet"
  ]
}

However, if we change the last command to use -o table instead, no output is printed.

        az network nic show --ids $NIC_ID \
          -g TutorialResources \
          --query '{IP:ipConfigurations[].publicIpAddress.id, Subnet:ipConfigurations[].subnet.id}' \
          -o table

Environment summary

Ubuntu 16 LTS (on WSL) zsh Installed via package az --version: 2.0.25

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
derekbekoecommented, Feb 15, 2018

@gsacavdm That’s a separate issue. There are a few keys we skip currently automatically and id is one of them. This is due to id appearing in almost every command result and them being very long so it’s atypical that you’d want to see it in the default table output of commands.

Change the key name and it will appear. https://github.com/Microsoft/knack/blob/master/knack/output.py#L152

If this is a real issue to you, please open a separate issue. 😃

0reactions
JasonRShavercommented, Aug 8, 2018

While we understand the scenario here, currently table requires some specific format to operate and moving it to be more free-form has unintended side-effects and additionally does not promote consistency.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Confused about CSV table output - Power Platform Community
Outside of the condition but within the scope, I create a table that has (should have) the output of the array. Then save...
Read more >
Table array with named variables that can contain different types
Tables store each piece of column-oriented data in a variable. Table variables can have different data types and sizes as long as all...
Read more >
Work with arrays | BigQuery - Google Cloud
To return the rows of a table where the array column contains a specific value, filter the results of IN UNNEST using the...
Read more >
Turn two arrays output into a table with dynamic updating in ...
I want to take the two arrays and output them in table format dynamically so I can change the color of the text...
Read more >
Querying arrays with complex types and nested structures
When you query tables within Athena, you do not need to create ROW data types, as they are already created from your data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found