@VisibleForTesting
  static List<String> parseSelectHeadersString(String str) {
    List<String> headers = new ArrayList<>();
    int structNesting = 0;
    boolean quotes = false;
    var headerBuilder = new StringBuilder();
    for (char ch : str.toCharArray()) {
      if (ch == '<') {
        structNesting++;
      } else if (ch == '>') {
        structNesting--;
      } else if (ch == '`') {
        quotes = !quotes;
      } else if (ch == ' ' && headerBuilder.isEmpty()) {
        continue; //skipping leading & training whitespaces
      } else if (ch == ',' && structNesting == 0 && !quotes) {
        headers.add(headerBuilder.toString());
        headerBuilder = new StringBuilder();
        continue;
      }
      headerBuilder.append(ch);
    }
    if (!headerBuilder.isEmpty()) {
      headers.add(headerBuilder.toString());
    }
    return headers;
  }
@Test
  void parsesSelectHeaderIntoColumnNames() {
    assertThat(ResponseParser.parseSelectHeadersString("`inQuotes` INT, notInQuotes INT"))
        .containsExactly("`inQuotes` INT", "notInQuotes INT");

    assertThat(ResponseParser.parseSelectHeadersString("`name with comma,` INT, name2 STRING"))
        .containsExactly("`name with comma,` INT", "name2 STRING");

    assertThat(ResponseParser.parseSelectHeadersString(
        "`topLvl` INT, `struct` STRUCT<`nested1` STRING, anotherName STRUCT<nested2 INT>>"))
        .containsExactly(
            "`topLvl` INT",
            "`struct` STRUCT<`nested1` STRING, anotherName STRUCT<nested2 INT>>"
        );
  }