public void createPipe(CreatePipeStmt stmt) throws DdlException {
        try {
            lock.writeLock().lock();
            Pair<Long, String> dbIdAndName = resolvePipeNameUnlock(stmt.getPipeName());
            boolean existed = nameToId.containsKey(dbIdAndName);
            if (existed) {
                if (!stmt.isIfNotExists() && !stmt.isReplace()) {
                    ErrorReport.reportSemanticException(ErrorCode.ERR_PIPE_EXISTS);
                }
                if (stmt.isIfNotExists()) {
                    return;
                } else if (stmt.isReplace()) {
                    LOG.info("Pipe {} already exist, replace it with a new one", stmt.getPipeName());
                    Pipe pipe = pipeMap.get(nameToId.get(dbIdAndName));
                    dropPipeImpl(pipe);
                }
            }

            // Add pipe
            long id = GlobalStateMgr.getCurrentState().getNextId();
            Pipe pipe = Pipe.fromStatement(id, stmt);
            putPipe(pipe);

            repo.addPipe(pipe);
        } finally {
            lock.writeLock().unlock();
        }

    }
@Test
    public void pollPipe() throws Exception {
        final String pipeName = "p3";
        String sql = "create pipe p3 properties('poll_interval' = '1') as " +
                "insert into tbl1 select * from files('path'='fake://pipe', 'format'='parquet')";
        createPipe(sql);

        Pipe p3 = getPipe(pipeName);
        Assert.assertEquals(0, p3.getLastPolledTime());
        p3.poll();

        Thread.sleep(1000);
        p3.poll();
        long timePoint = System.currentTimeMillis() / 1000;
        long diff = timePoint - p3.getLastPolledTime();
        Assert.assertTrue("Time diff: " + diff + " should less than 10 seconds", diff >= 0 && diff <= 10);

        p3.poll();
        diff = p3.getLastPolledTime() - timePoint;
        Assert.assertTrue("Time diff: " + diff + " should less than 10 seconds", diff >= 0 && diff <= 10);
    }