Skip to content

Is Map Support ? #561

Closed

Description

@spz0507

The newest feature is ClickHouse/ClickHouse#15806

Activity

  1. spz0507 commented on Feb 2, 2021

    @spz0507
    Author
  2. added this to the 0.3.0 release milestone on Feb 2, 2021
  3. zhicwu commented on Feb 2, 2021

    @zhicwu
    Contributor

    Link #560

  4. self-assigned this
    on Mar 5, 2021
  5. linked a pull request that will close this issueSupport more data types #589on Mar 5, 2021
  6. zhicwu commented on Mar 5, 2021

    @zhicwu
    Contributor

    Still need some more time to test, but you will be able to use Map like below:

    public void testMaps() throws Exception {
        try (Statement s = conn.createStatement()) {
            s.execute("DROP TABLE IF EXISTS test_maps");
            s.execute(
                    "CREATE TABLE IF NOT EXISTS test_maps(ma Map(Integer, Array(String)), mi Map(Integer, Integer), ms Map(String, String)) ENGINE = Memory");
            s.execute("insert into test_maps values ({1:['11','12'],2:['22','23']},{1:11,2:22},{'k1':'v1','k2':'v2'})");
    
            try (ResultSet rs = s.executeQuery("select * from test_maps")) {
                assertTrue(rs.next());
                compareMap(rs.getObject("ma"),
                        Utils.mapOf(1, new String[] { "11", "12" }, 2, new String[] { "22", "23" }));
                compareMap(rs.getObject("mi"), Utils.mapOf(1, 11, 2, 22));
                compareMap(rs.getObject("ms"), Utils.mapOf("k1", "v1", "k2", "v2"));
            }
    
            s.execute("truncate table test_maps");
        }
    
        try (PreparedStatement s = conn.prepareStatement("insert into test_maps values(?,?,?)")) {
            s.setObject(1, Utils.mapOf(1, new String[] { "11", "12" }, 2, new String[] { "22", "23" }));
            s.setObject(2, Utils.mapOf(1, 11, 2, 22));
            s.setObject(3, Utils.mapOf("k1", "v1", "k2", "v2"));
            s.execute();
        }
    
        try (Statement s = conn.createStatement()) {
            try (ResultSet rs = s.executeQuery("select * from test_maps")) {
                assertTrue(rs.next());
                compareMap(rs.getObject("ma"),
                        Utils.mapOf(1, new String[] { "11", "12" }, 2, new String[] { "22", "23" }));
                compareMap(rs.getObject("mi"), Utils.mapOf(1, 11, 2, 22));
                compareMap(rs.getObject("ms"), Utils.mapOf("k1", "v1", "k2", "v2"));
            }
        }
    }
  7. added
    data-types
    jdbc
    legacy
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

data-typesenhancementjdbclegacy

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions