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

How to use named_collections? #33117

Closed
zotann opened this issue Dec 23, 2021 · 15 comments
Closed

How to use named_collections? #33117

zotann opened this issue Dec 23, 2021 · 15 comments
Labels
question Question?

Comments

@zotann
Copy link

zotann commented Dec 23, 2021

Added connection parameters to config.xml

     <named_collections>
         <pg_conn>
                 <host>10.200.20.20</host>
                 <port>5432</port>
                 <user>postgres</user>
                 <password>pass</password>
                 <db>olap2</db>
         </pg_conn>
     </named_collections>

The server ClickHouse was rebooted.

How to use named_collections?

 create table   src_133.pg_cube_test2
 (
     clnd_id integer ,
     okved_id integer  ,
     type_id integer ,
     terr_id integer  ,
     fact1  Nullable(Float64),
     fact2 Nullable(Float64),
     fact3 Nullable(Float64),
     fact4 Nullable(Float64),
     group_id Nullable(Float64)

 ) 
 engine = PostgreSQL(pg_conn,  table = 'cube_data_aggr', sheme = 'src_133'    );

Code: 36. DB::Exception: There is no collection named pg_conn in config. (BAD_ARGUMENTS) (version 21.12.2.17 (official build))

@kssenii. i need help

@zotann zotann added the question Question? label Dec 23, 2021
@kssenii
Copy link
Member

kssenii commented Dec 23, 2021

Added connection parameters to config.xml

very strange, your configuration is correct, are you sure you put it on correct level in config and the server indeed uses that config?

@zotann
Copy link
Author

zotann commented Dec 23, 2021

Looked at the source file. It is required to create a file named_collections.xml and describe the structure of the collection there.

@kssenii
Copy link
Member

kssenii commented Dec 23, 2021

Not it is not, you can just put in config.xml.

@zotann
Copy link
Author

zotann commented Dec 23, 2021

very strange, your configuration is correct, are you sure you put it on correct level in config and the server indeed uses that config?

I'm confused.
In which file should you create the tag?
сonfig.xml or named_collections.xml?

@zotann
Copy link
Author

zotann commented Dec 23, 2021

Not it is not, you can just put in config.xml.

Where do I add the <named_collection>....</named_collection> tag in file сonfig.xml ?

@kssenii
Copy link
Member

kssenii commented Dec 23, 2021

Looked at the source file.

When you put files in config.d directory they can be used as config files and can be named not only as config.xml -- same as the file name_collection.xml that you saw in the source file.

So putting your configuration will also work if you out it in config,xml as well as it will work if you out it in config.d directory in a dile with different name.

@kssenii
Copy link
Member

kssenii commented Dec 23, 2021

Where do I add the <named_collection>....</named_collection> tag in file сonfig.xml ?

<named_collection> -- no, need s at the end -- named_collections

Yes, you can put it just in config.xml

@zotann
Copy link
Author

zotann commented Dec 23, 2021

@kssenii. its true?

	<named_collections> 
	    <pg_conn>
		<host>10.200.20.20</host>
		<port>5432</port>
		<username>postgres</user>
		<password>pass</password>
		<database>olap2</database>  
	    </pg_conn>  
	</named_collections> 

@kssenii
Copy link
Member

kssenii commented Dec 23, 2021

Yes, totally correct.

@zotann
Copy link
Author

zotann commented Dec 23, 2021

Config.xml
image

Query
image

Error
Code: 36. DB::Exception: There is no collection named pg_conn in config. (BAD_ARGUMENTS) (version 21.12.2.17 (official build))

@zotann
Copy link
Author

zotann commented Dec 23, 2021

Completed clickhouse-server restart

@zotann
Copy link
Author

zotann commented Dec 23, 2021

Yes, totally correct.

What am I doing wrong?

@zotann
Copy link
Author

zotann commented Dec 23, 2021

Understood. The tag was wrong. And "schema" but not "scheme".

	<named_collections> 
	    <pg_conn>
		<host>10.200.20.20</host>
		<port>5432</port>
		<user>postgres</user>
		<password>pass</password>
		<database>olap</database>  
	    </pg_conn>    
	</named_collections> 

engine = PostgreSQL(pg_conn , table = 'cube_data_aggr', schema = 'src_133' );

@zotann zotann closed this as completed Dec 24, 2021
@zotann
Copy link
Author

zotann commented Dec 24, 2021

This goood

@liuyuchuan
Copy link

hello
i want to know which version add the tags of named_collections?

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

No branches or pull requests

3 participants