66import java .sql .DriverPropertyInfo ;
77import java .sql .SQLException ;
88import java .sql .SQLFeatureNotSupportedException ;
9- import java .util .ArrayList ;
10- import java .util .Collections ;
11- import java .util .HashMap ;
12- import java .util .LinkedHashMap ;
13- import java .util .List ;
14- import java .util .Map ;
15- import java .util .Properties ;
16- import java .util .ServiceLoader ;
9+ import java .util .*;
1710import java .util .Map .Entry ;
1811
1912import com .clickhouse .client .ClickHouseClient ;
@@ -49,6 +42,32 @@ public class ClickHouseDriver implements Driver {
4942
5043 static final java .util .logging .Logger parentLogger = java .util .logging .Logger .getLogger ("com.clickhouse.jdbc" );
5144
45+ public static String frameworksDetected = null ;
46+
47+ public static class FrameworksDetection {
48+ private static final List <String > FRAMEWORKS_TO_DETECT = List .of ("apache.spark" );
49+ static volatile String frameworksDetected = null ;
50+
51+ private FrameworksDetection () {
52+ }
53+ public static String getFrameworksDetected () {
54+ if (frameworksDetected == null ) {
55+ Set <String > inferredFrameworks = new LinkedHashSet <>();
56+ for (StackTraceElement ste : Thread .currentThread ().getStackTrace ()) {
57+ for (String framework : FRAMEWORKS_TO_DETECT ) {
58+ if (ste .toString ().contains (framework )) {
59+ inferredFrameworks .add (String .format ("(%s)" , framework ));
60+ }
61+ }
62+ }
63+
64+ frameworksDetected = String .join ("; " , inferredFrameworks );
65+ }
66+ return frameworksDetected ;
67+ }
68+
69+ }
70+
5271 static {
5372 String str = ClickHouseDriver .class .getPackage ().getImplementationVersion ();
5473 if (str != null && !str .isEmpty ()) {
@@ -115,7 +134,6 @@ public static Map<ClickHouseOption, Serializable> toClientOptions(Properties pro
115134 options .put (o , ClickHouseOption .fromString (e .getValue ().toString (), o .getValueType ()));
116135 }
117136 }
118-
119137 return options ;
120138 }
121139
@@ -128,7 +146,7 @@ private DriverPropertyInfo create(ClickHouseOption option, Properties props) {
128146
129147 Class <?> clazz = option .getValueType ();
130148 if (Boolean .class == clazz || boolean .class == clazz ) {
131- propInfo .choices = new String [] { "true" , "false" };
149+ propInfo .choices = new String []{ "true" , "false" };
132150 } else if (clazz .isEnum ()) {
133151 Object [] values = clazz .getEnumConstants ();
134152 String [] names = new String [values .length ];
0 commit comments