Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"can't find meta" error in prepare/execute #27

Open
n00bik opened this issue Apr 19, 2019 · 3 comments
Open

"can't find meta" error in prepare/execute #27

n00bik opened this issue Apr 19, 2019 · 3 comments

Comments

@n00bik
Copy link

n00bik commented Apr 19, 2019

Hello.

I try to check if records already exist, and get error = "An exception occurred while executing 'SELECT 1 dupl FROM payments WHERE order_id= :order_id AND appid= :appid LIMIT 1' with params ["xxx=:1:11", "yyy-Amazon"]:\n\nCan`t find meta"}

My code:
$stmt = $conn->prepare('SELECT 1 dupl FROM payments WHERE order_id= :order_id AND appid= :appid LIMIT 1'); $stmt->bindValue('order_id', $order_id); $stmt->bindValue('appid', $j->app_id); $stmt->execute(); while ($row = $stmt->fetch()) { file_put_contents('ch_dupl_' . date('Y-m-d') . '_' . $tbl . '_' . $j->app_id . '_' . uniqid() . '.json', json_encode($j)); return true; }

My table structure:
CREATE TABLE default.payments ( cohort Date, installdatetime DateTime, attributedtouchtime Nullable(DateTime), ... appid String, ... order_id String, ... ) ENGINE = MergeTree() PARTITION BY cohort ORDER BY appid SETTINGS index_granularity = 8192;

@n00bik
Copy link
Author

n00bik commented Apr 19, 2019

Rewrite prepare/execute to simple fetchColumn wihtout limit 1
if ($conn->fetchColumn("SELECT order_id FROM payments WHERE order_id='{$order_id}' AND appid='{$j->app_id}'")) { file_put_contents('ch_dupl_' . date('Y-m-d') . '_' . $tbl . '_' . $j->app_id . '_' . uniqid() . '.json', json_encode($j)); return true; }
error log is the same=
An exception occurred while executing 'SELECT order_id FROM payments WHERE order_id='xxx' AND appid='yyy'':\n\nCan`t find meta"

Thank you in advance!

@n00bik n00bik changed the title can't find meta error in prepare/execute "can't find meta" error in prepare/execute Apr 19, 2019
@Sufir
Copy link

Sufir commented May 8, 2019

I also have this error.

    $stmt = $conn->prepare('SELECT COUNT(*) FROM user_view WHERE view_date BETWEEN :dateBegin AND :dateEnd');
    $stmt->bindValue('dateBegin', $start->format("Y-m-d"));
    $stmt->bindValue('dateEnd', $end->format("Y-m-d"));
    $stmt->execute();
An exception occurred while executing 'SELECT COUNT(*) FROM user_view WHERE view_date BETWEEN :dateBegin AND :dateEnd' with params ["2019-05-01", "2019-05-31"]:

Can`t find meta

@erikbaan
Copy link

erikbaan commented Apr 15, 2021

I'm running into the same "Can`t find meta" error, using a CTE.

This is caused by the following code in ClickHouseStatement.processViaSMI2 :

        $this->rows =
            stripos($sql, 'select') === 0 ||
            stripos($sql, 'show') === 0 ||
            stripos($sql, 'describe') === 0 ?
                $this->smi2CHClient->select($sql)->rows() :
                $this->smi2CHClient->write($sql)->rows();

The statement must begin with select to use the appropriate methods.
Maybe your query is not starting with SELECT (but has some weird whitespace or something?) @n00bik and @Sufir ?

I've made a fork that quickfixes this issue for CTE's: easyterrabv@19b0695

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants