@Override
  @SuppressWarnings("unchecked")
  public int run() throws IOException {
    Preconditions.checkArgument(targets != null && targets.size() >= 1, "A Parquet file is required.");
    Preconditions.checkArgument(targets.size() == 1, "Cannot process multiple Parquet files.");

    String source = targets.get(0);

    try (ParquetFileReader reader = ParquetFileReader.open(getConf(), qualifiedPath(source))) {
      MessageType schema = reader.getFileMetaData().getSchema();
      ColumnDescriptor descriptor = Util.descriptor(column, schema);
      PrimitiveType type = Util.primitive(column, schema);
      Preconditions.checkNotNull(type);

      DictionaryPageReadStore dictionaryReader;
      int rowGroup = 0;
      while ((dictionaryReader = reader.getNextDictionaryReader()) != null) {
        DictionaryPage page = dictionaryReader.readDictionaryPage(descriptor);

        if (page != null) {
          console.info("\nRow group {} dictionary for \"{}\":", rowGroup, column);
          Dictionary dict = page.getEncoding().initDictionary(descriptor, page);
          printDictionary(dict, type);
        } else {
          console.info("\nRow group {} has no dictionary for \"{}\"", rowGroup, column);
        }

        reader.skipNextRowGroup();

        rowGroup += 1;
      }
    }

    console.info("");

    return 0;
  }
@Test
  public void testShowDirectoryCommandWithoutDictionaryEncoding() throws IOException {
    File file = parquetFile();
    ShowDictionaryCommand command = new ShowDictionaryCommand(createLogger());
    command.targets = Arrays.asList(file.getAbsolutePath());
    // the 'double_field' column does not have dictionary encoding
    command.column = DOUBLE_FIELD;
    command.setConf(new Configuration());
    Assert.assertEquals(0, command.run());
  }